36,312 views
2 votes
2 votes
What is thesql command to list the total sales by customer , month , and product, with subtotals by customer and by month and a grand total for all product sales

User Larrydag
by
3.4k points

1 Answer

8 votes
8 votes

Answer:

The answer is below

Step-by-step explanation:

The the sql command to list the total sales by customer , month , and product, with subtotals by customer and by month and a grand total for all product sales is:

SELECT S.CUS_CODE, T.TM_MONTH, S.P_CODE,

SUM(S.SALE_UNITS*S.SALE_PRICE) AS "TOTSALES"

FROM DWDAYSALESFACT AS S INNER JOIN DWTIME AS T ON S.TM_ID =

T.TM_ID

GROUP BY S.CUS_CODE,T.TM_MONTH,S.P_CODE WITH ROLLUP;

User Jonathon Oates
by
2.4k points