PdfPrep.com

How should you complete the Transact-SQL statement?

DRAG DROP

You are a database administrator for an online retail store. You create a table to track orders by running the following Transact-SQL statement:

You need to create a report that includes the following information:

.- Total sales for each year

.- Total sales for each category

.- Total sales for each category per year

How should you complete the Transact-SQL statement? To answer, drag the appropriate Transact-SQL segment to the correct locations. Each Transact-SQL segment may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.

NOTE: Each correct selection is worth one point.

Answer:

Explanation:

Box 1: GROUP BY Box 2: CUBE GROUP BY CUBE creates groups for all possible combinations of columns. For GROUP BY CUBE (a, b)

the results has groups for unique values of (a, b), (NULL, b), (a, NULL), and (NULL, NULL). Example: This code runs a GROUP BY CUBE operation on Country and Region. SELECT Country, Region, SUM(Sales) AS TotalSales

FROM Sales GROUP BY CUBE (Country, Region); References: https://docs.microsoft.com/en-us/sql/t-sql/queries/select-group-by-transact-sql

Exit mobile version