3 SQL Statements. Here are the relational database tables PARTS(PNO, PNAME, QOH,
ID: 3746053 • Letter: 3
Question
3 SQL Statements.
Here are the relational database tables
PARTS(PNO, PNAME, QOH, PRICE, OLEVEL)
CUSTOMERS(CNO, CNAME, STREET, ZIP, PHONE)
EMPLOYEES(ENO, ENAME, ZIP, HDATE)
ZIPCODES(ZIP, CITY)
ORDERS(ONO, CNO, ENO, RECIEVED, SHIPPED)
ODETAILS(ONO, PNO, QTY)
1.Retrieve a list of part numbers, part name, and total quantity ordered for that part. Produce a listing sorted in decreasing order of the total quantity ordered.
2.Retrieve the average waiting time(number of days) for all orders. The waiting time is defined as the difference between shipping date and order date received date rounded up the the nearest day.
3.For each employee, retrieve his number, name, and total sales in a given year, say 2005.
Explanation / Answer
1.
SELECT PNO, PNAME, QOH FROM PARTS;
SELECT SUM(QOH)
ORDER BY QOH DESC;
FROM PARTS;
-----------------------------------------------------------------
2.
SELECT * FROM ORDER
WHERE ORDERDATE BETWEEN SHIPPED AND RECEIVED;
--------------------------------------------------------------
3.
SELECT SUM(QOH), ENO, ENAME;
FROM EMPLOYEES;
WHERE (YEAR (ORDERDATE) = 2005);
----------------------------------------------------------------
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.