Friday, March 22, 2013

[SQL Server] Need help with Select statement!!

[SQL Server] Need help with Select statement!!


Need help with Select statement!!

Posted: 22 Mar 2013 07:22 AM PDT

final project is due tonight at midnight and i cant finish up these select statements a. Find all those customers who have not purchased anything from Niles Video Inc.b. Get the total number of DVDs and video tapes sold per genre.c. Get the average number of DVDs per purchase.heres the er model [IMG]http://i45.tinypic.com/34qx021.png[/IMG]followed by the relational[IMG]http://i47.tinypic.com/154gjzn.png[/IMG]please let me know if my er model or relational model is wrong

Customers last order date

Posted: 21 Mar 2013 05:35 PM PDT

Hi All,I'm having a bit of trouble with the following query, I get the results I need with the exception of the "last_order_date" field... it is emptyWhat I'm trying to do is this...Pull the records for the days orders and also return the most recent order for each customer (if they have one).This is what I have... your help is greatly appreciatedselecto.idOrderCustom, o.orderDate, o.total, o.idCustomer,c.name, c.lastName, c.customerCompany, c.email, c.city, c.stateCode,c.phone, last_order_datefromorders oLEFT JOIN customers c ON o.idCustomer = c.idCustomerLEFT JOIN(select top 1orders.orderDate as last_order_date,orders.idCustomer from orders whereorders.orderDate < '3/21/2013'AND orders.orderStatus = 4order by orders.orderDate desc) l ON o.idCustomer = l.idCustomerwhereo.orderDate = '3/21/2013'ThanksRick

No comments:

Post a Comment

Search This Blog