MySQL Forums
Forum List  »  Newbie

24h and still haven't executed a working MySQL command
Posted by: Connor McMahon
Date: February 14, 2017 10:48PM

I have tried seemingly hundreds of SQL code variations online and have been unable to simply find one that give me TOTAL "Net_Sales" summed for a specific year. The data charts I'm working with are quite simple (example below):


Stores_NS

Store Date Product_Category Net_Sales
1 1/1/2014 Beauty $100
1 6/20/2014 Ladies Shoes $250
1 7/1/2015 Ladies Shoes $3,000
2 3/1/2012 Beauty $490
2 5/4/2014 Beauty $1,500
3 11/1/2015 Beauty $600
4 12/31/2013 Home $2,250
4 2/17/2014 Home $1,800
5 8/16/2013 Beauty $550

To find the total net sales for a specific year, here is the code I keep struggling with getting right:

SELECT ???,SUM(Net_Sales) as totalsales
FROM Stores_NS
GROUP BY ?Date? WITH ROLLUP

Any help is very much appreciated! Thank you.

Options: ReplyQuote


Subject
Written By
Posted
24h and still haven't executed a working MySQL command
February 14, 2017 10:48PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.