sql server - SQL Northwind Practice -
i have practice question:
show each order item – customer name , order id, product name, ordered quantity, product price , total price (ordered quantity * product price) , gap between ordered date , shipped date (the gap in days). order order id.
northwind of course.
my query was:
select c.contactname, o.orderid, p.productname, od.quantity, od.unitprice, od.quantity * od.unitprice [total price] orders o, customers c, products p, [order details] od c.customerid = o.customerid , o.orderid = od.orderid , od.productid = p.productid order o.orderid;
the thing not is: "gap between date , shipped date". don't it.
thanks.
pertinent question, gap between ordered date , shipped date refers calculated value of:
datediff(day, date_ordered, date_shipped) gapdays
using sql datediff
() function, date_ordered
, date_shipped
corresponds field names in table (you may need rename them per actual fields; also, correct join syntax explained here; https://msdn.microsoft.com/en-us/library/zt8wzxy4.aspx).
hope may help.
Comments
Post a Comment