How would you show the subtotals for each state


Homework: Data Science and Big Data Analysis

i. How would you use GROUPING SETS to produce the same results as the following GROUP BY CUBE?

SELECT state, productID, SUM(volume) FROM sales GROUP BY CUBE (state, productID) ORDER BY state, productID

ii. How would you show the subtotals for each week, for each state, and for each product? (No other totals or grand totals are required.) Suppose the table structure is

TABLE sales (productID VARCHAR, state CHAR(2), week DATE, volume INT)

iii. Discuss the utility of grouping and group_id functions

iv. Describe below how this code will work:

SELECT dt, region, revenue,
count(*) OVER (twdw) AS moving_count,
avg(revenue) OVER (twdw) AS moving_average
FROM moving_average_data mad
WINDOW twdw AS (PARTITION BY region
ORDER BY dt RANGE BETWEEN
'7 days'::interval PRECEDING AND
'0 days'::interval FOLLOWING
ORDER BY region, dt

Format your homework according to the give formatting requirements:

• The answer must be using Times New Roman font (size 12), double spaced, typed, with one-inch margins on all sides.

• The response also includes a cover page containing the student's name, the title of the homework, the course title, and the date. The cover page is not included in the required page length.

• Also include a reference page. The references and Citations should follow APA format. The reference page is not included in the required page length.

Request for Solution File

Ask an Expert for Answer!!
Database Management System: How would you show the subtotals for each state
Reference No:- TGS03025563

Expected delivery within 24 Hours