Question

K3 K3 School of CS & IT, RMIT Introduction to Database Systems Tutorial Sheet 2: SQL The database below is for a department s2. Give SQL expressions for each of the following queries. (a) What is the potential value of all current stock? (b) Which st(a) create view StaffSales (Staff, TotSales) as select Staff, sum( Item.Price * Sale.Numsold ) from Sale, Item where Sale.Ite

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1.

a)

SELECT i.DESCRIP

FROM ITEM i, SALE s

WHERE i.TYPE=s.ITEM

AND s.CLIENT='Cilla';

b)

SELECT DISTINCT STAFF

FROM SALE

WHERE SDATE= '19980311';

c)

SELECT TYPE

FROM STOCK

WHERE NUMSTOCK= 0;

d)

SELECT TYPE

FROM STOCK

WHERE TYPE NOT IN(SELECT DISTICT ITEM FROM SALE);

e)

SELECT NAME

FROM STAFF

WHERE POSITION= 'Clerk'

AND (STAFF NOT IN(SELECT DISTINCT STAFF FROM SALE));

f)

SELECT POSITION FROM STAFF

WHERE NAME IN(SELECT DISTINCT STAFF FROM SALE)

g)

SELECT st.TYPE

FROM STOCK st, SALE sa

WHERE st.TYPE= sa.ITEM

HAVING SUM(sa.NUMSOLD) > (st.NUMSTOCK)

GROUP BY st.TYPE;

Add a comment
Know the answer?
Add Answer to:
K3 K3 School of CS & IT, RMIT Introduction to Database Systems Tutorial Sheet 2: SQL...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Exercise 3 [12.5 marks] Given the Restaurant management system database that contains the following tables (primary...

    Exercise 3 [12.5 marks] Given the Restaurant management system database that contains the following tables (primary keys are underlined and foreign keys are preceded with #): Customer (customerID,customerFirstName,customerLastName,customerAddress) Oreder (orderID,orderDate, #customerID,#menuItemID,#staffID) MenuItem(menuItemID, menuItemName,ingredients,type,availability) Staff(staffID, staffName, staffPhoneNumber, staffRole ) OrderPayment(paymentID,paymentAmount,#orderID,#staffID) 1) Without using DISTINCT, write the SQL query equivalent to the following one:[1.5 marks] SELECT DISTINCT menuItemName FROM MenuItem WHERE type = ‘Vegetarian’ OR availability= ‘Yes’; 2) Express the following queries in SQL: a) Find the number of orders placed by...

  • The relational schema for the Academics database is as follows DEPARTMENT(deptnum, descrip, instname, deptname, state,...

    The relational schema for the Academics database is as follows DEPARTMENT(deptnum, descrip, instname, deptname, state, postcode) ACADEMIC(acnum, deptnum*, famname, givename, initials, title) PAPER(panum, title) FIELD(fieldnum, id, title) INTEREST(fieldnum* acnumk, descrip) Some notes on the Academics database An academic department belongs to one institution (instname) and often has many academics. An academic only works for one department. Research papers (PAPER) are often authored by several academics, and of course an academic often writes several papers (AUTHOR) A research field (FIELD) often...

  • Question 3. SQL (5 points). In addition to the lecture notes, you should also study by yourself t...

    Question 3. SQL (5 points). In addition to the lecture notes, you should also study by yourself the SQL Plus tutorial on Canvas (the Oracle section) and other resources for Oracle syntax and useful functions. The relational schema for the Academics database is as follows: DEPARTMENT(deptnum, descrip, instname, deptname, state, postcode) ACADEMIC(acnum, deptnum, famname, givename, initials, title) PAPER(panum, title) AUTHOR(panum*. acnum) FIELD(fieldnum, id, title) INTEREST(fieldnum* acnum*, descrip) Some notes on the Academics database An academic department belongs to one institution...

  • Prepare and execute each of the queries listed using the "Adventureworks2012" database in SQL: Server: http://msftdbprodsamples.codeplex.com/releases/view/93587...

    Prepare and execute each of the queries listed using the "Adventureworks2012" database in SQL: Server: http://msftdbprodsamples.codeplex.com/releases/view/93587 When all of your queries are complete, cut and paste the SQL Syntax into a word document. In order to see what the column names are, you need to click on the table and then Columns to see the field names. Make sure to include column headings that make sense in the queries (use the as “Field Name” after the field selected). Multi-table Queries...

  • You will develop an E-Commerce database used to maintain customers, products and sales information. You are...

    You will develop an E-Commerce database used to maintain customers, products and sales information. You are required to 1) gather and analyze requirements 2) design logical structure of the database 3) create stored procedures to develop the tables and insert the data 4) write SQL statements for data extraction and reporting. Throughout the course of this semester you have analyzed the requirements for an eCommerce database, designed and developed your database. As a class we have gone through the process...

  • MYSQL Applied Database I just want to make sure that the syntax looks okay for my...

    MYSQL Applied Database I just want to make sure that the syntax looks okay for my database SQL statements, any help would be much appreciated: 1.A query that asks for customer star review for Tony Stark on Opportunity Detail. SELECT CONCAT (employee_first_name,' ',employee_last_name) AS                            employee_name, review_star_count, FROM customer_reviews, JOIN e employees ON employee_id =employee_id, WHERE employee_id=4 AND opportunity_id=1; 2.A query that shows how many orders Additional Dot Twain License, in an order totaling over $900. SELECT product_name, COUNT(o.OrderID) AS...

  • Use the HR database for all the questions in this lab. For each item in this lab, paste the SQL y...

    Use the HR database for all the questions in this lab. For each item in this lab, paste the SQL you used to complete the task and the number of rows retrieved. Ensure you follow the coding standards listed in the ETSU SQL standards guide found on D2L. Save this document as a PDF and name it your_name_lab7.pdf Display the employees’ first name, last name and phone number of employees with salaries greater than 10,000 dollars. SELECT first_name, last_name, phone_number,...

  • Write an SQL query to list those properties that have never been sold. Design Tip When a property has sold, its information can be found in Sales table and vice versa. List each property with the foll...

    Write an SQL query to list those properties that have never been sold. Design Tip When a property has sold, its information can be found in Sales table and vice versa. List each property with the following four columns: property_id, primary_purpose, locality, and the area. Name the area coulmn as "Area". (Since the dataset might be incomplete, return "N/A" when the area is unknown for a property.) So the problem I got is that I got very similar output as...

  • database and sql problme THE QUESTIONS 3, 4,5 and 6 REFER TO THE RELATIONAL TABLES LISTED...

    database and sql problme THE QUESTIONS 3, 4,5 and 6 REFER TO THE RELATIONAL TABLES LISTED BELOW CREATE TABLE Department ( DECIMAL(5) VARCHAR(30) CHAR(5) DATE NOT NULL NOT NULL NOT NULL * Department number /*Department name * Department manager number */ /Manager start date DNumber DName Manager MSDate CONSTRAINT Department_PK PRIMARY KEY(DNumber) CONSTRAINT Department_CK UNIQUE(DName) CREATE TABLE DeptLocation DECIMAL(5) VARCHAR(50) NOT NULL NOT NULL DNumber * Department number */ * Department location */ Address CONSTRAINT DeptLocation_PK PRIMARY KEY(DNumber, Address) CONSTRAINT...

  • Book: Fundamental of database systems Chapter 5 exercise 5.9 Figure 3-6 here provides examples on how...

    Book: Fundamental of database systems Chapter 5 exercise 5.9 Figure 3-6 here provides examples on how to answer this question: Photos - 20190906_111020[3691].jpg -ox See all photos + Add to Edit & Create Share : Q u ♡ 2 # d. A view that has the project name, controm of employees, and total hours worked per week on the project for each project with more than one employee working on it. 5.9. Consider the following view, DEPT SUMMARY, defined on...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT