BUS 2 112 Section 8 Sprint 2000 Assignment 3 Answers
BUS 2 112 Section 8 Sprint 2000 Assignment 3 Answers
BUS 2 112 Section 8 Sprint 2000 Assignment 3 Answers
(1) Write an SQL command to display the order number, customer number, order date, and items ordered for Order # 1001. SELECT Order_t.Order_ID,Order_t.Customer_ID, Order_t.Order_date, Order_line_t.Product ID,Orderline_t.Quantity FROM Customer_t I!!ER "OI! Order_t O! Customer_t.Customer_ID# Order_t.Customer_ID$I!!ER "OI! Order_line_t O! Order_t.Order_ID # Order_linet.Order_ID %&ERE Order_t.Order_ID$#'(('$$) ( ) Write an SQL command to display each item ordered for Order #1001, its unit price, and the total price for each item ordered. SELECT Order_line_t.Product_ID, Product_t.unit_Price, Sum Order_line_t.Quantity$*Poduct_t.+nit_Price ,S Total FROM Product_t I!!ER "OI! Order_line_t O! Product_t.Order_ID # Order_line_t.Product_ID -RO+P ./ Order_line_t.Product_ID, Product_t0+nit_Price, Order_line_t.Order_ID &,1I!- Order_line_t.Order_ID$#'(('$$) (!) Write an SQL command to total the cost of Order # 1001. "his solution use the results of #uestion ( ), sa$e as a #uery named %# % SELECT 2345. Order_ID, Sum 2345.Total$ ,s Order_Total FROM 2345 -RO+P ./ 2345.Order_ID) (&) Write an SQL command that 'ill find any customers 'ho ha$e not placed orders SELECT Customer_t.Customer_ID, Customer_t.Customer_name FROM Customer_t %6ere E7ists SELECT*FROM Order_t %&ERE Customer_t.Customer_ID#Order8t.Customer_ID$$#False$$) (() Write an SQL #uery to produce a list of all products and the number of times each product has been ordered. T6is 9uery re9uires an outer :oin since some ;roducts may not 6a<e =een ordered. Since many SQL systems do not 6a<e an outer :oint o;erator, o>ten t6is ty;e o> 9uery must use t6e +!IO! command. T6e >ollo?in@ ans?er uses
t6is second a;;roac6 since it ?ill ?orA ?it6 almost any system. ,lso, note t6at t6e 9uestion ?ants t6e num=er o> times a ;roduct 6as =een ordered, not t6e total 9uantity ordered. SELECT Product_t.Product_ID, Product_!ame, CO+!T *$ FROM Product_t I!!ER "OI! Order_line_t O! Product_.Product_ID # Order_line_t.Product_ID -RO+P ./ Product_t.Product_ID,Product_!ame +!IO! SELECT Product_ID, Product_!ame,( FROM Product_t %&ERE EBISTS SELECT*FROM Order_line_t %&ERE Order_line_t.Product_ID#Product_t.Product_ID$$#F,LSE$)