Provide a running total for sales of each item in store 5 in January and generate output that is ready to export into a graphing program.
SELECT Item, SalesDate, CSUM(Revenue,Item,SalesDate) AS CumulativeSales FROM (SELECT Item, SalesDate, SUM(Sales) AS Revenue FROM DailySales WHERE StoreId=5 AND SalesDate BETWEEN '1/1/1999' AND '1/31/1999' GROUP BY Item, SalesDate) AS ItemSales ORDER BY SalesDate;
The result might like something like the following table.
Item | SalesDate | CumulativeSales |
---|---|---|
InstaWoof dog food | 01/01/1999 | 972.99 |
InstaWoof dog food | 01/02/1999 | 2361.99 |
InstaWoof dog food | 01/03/1999 | 5110.97 |
InstaWoof dog food | 01/04/1999 | 7793.91 |