views:

11

answers:

0

Hi All,

I have 4 tables Customers, Orders, Order details and Comments in my db. Customer can have many orders/Comments. Orders can have multiple OrderItems(OrderDetails).

What I need is the SQL statement to return the following:- Customerid, CustomerName, TotalOrders, Total OrderItems and NoOfRecentComments.

TotalOrders would be the total number of records in Orders table against customer TotalOrderItems would be the total number of records in OrderDetails table against all the orders for that customer NoOfRecentComments would be the number of Comments added against customer in last week only.

Thanks in advance