Calculate sales total between 2 dates

Thread: Calculate sales total between 2 dates

1. Senior Member
Join Date
Dec 1969
Posts
169

Calculate sales total between 2 dates

This is a simple one for you guys...<BR><BR>I have 3 tables, Products, Orders, OrderDetails. <BR>Products is a list of product with their SKUs. <BR>Orders has the sale details, including date, total, ordernumber etc. <BR>OrderDetails links to Orders with the field OrderID and has quantity, productSKU, Price etc.<BR><BR>I want to calcluate how many of each product I have sold in a set time period. Any ideas what the SQL should look like ?

2. Senior Member
Join Date
Dec 1969
Posts
688

RE: Calculate sales total between 2 dates

I think something like this should work:<BR><BR>[code language="T-SQL"]<BR>Select ProductName, Sum(OrderDetailsQuantity) From Products<BR>INNER JOIN OrderDetails ON Products.ProductID = OrderDetails.ProductID<BR>INNER JOIN Orders ON OrderDetails.OrderID = Orders.OrderID<BR>WHERE OrderDate BETWEEN YourStartDate AND YourEndDate<BR>GROUP BY ProductName<BR>[/code]

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•