Fibob Fibob - 4 months ago 6
SQL Question

SQL Basic Query Help! Sum of Sales on Specific date for Specific Products

I need to write a quick bit of code and for the life of me can't work out how to do it - it's been so long since I've had to use SQL, and I've had a mind-lapse.

I need to sum the sales for product A, product B and product C - one total for each product, for

November 27th 2015
(in date format
YYYY_MM-DD
).

Answer

The basic idea is this

SELECT
ProductName
,SUM(SalesQuantity) Sales
FROM TableName
WHERE SalesDate = '2015_11-27'
    AND ProductName IN ('A','B','C')
GROUP BY ProductName

But it all depends on your data structure.

Also, if this is homework then just say. We'd be happy to help you along but doing it for you is not going to help you at all.

Comments