Design SQL queries for the supermarket example that will return the information needed to make a table similar to that of Figure 17.10, except that markets are aggregated by state, and time is aggregated by months.
a. Use CUBE or ROLLUP operators.
b. Do not use CUBE or ROLLUP operators.
c. Compute the result table.
a.
SELECT M.Region, T.month, SUM(S.Sales_Amt)
FROM Sales S, Market M, Time T
WHERE S.Market_Id = M.Market_Id AND S.Time_Id = T.Time_Id
GROUP BY CUBE (M.Region, T.month)
b.
SELECT M.Region, T.month, SUM(S.Sales_Amt)
FROM Sales S, Market M, Time T
WHERE S.Market_Id = M.Market_Id AND S.Time_Id = T.Time_Id
GROUP BY M.Region, T.month
SELECT M.Region, SUM(S.Sales_Amt)
FROM Sales S, Market M
WHERE S.Market_Id = M.Market_Id
GROUP BY M.Region
SELECT T.month, SUM(S.Sales_Amt)
FROM Sales S, Time T
WHERE S.Time_Id = T.Time_Id
GROUP BY T.month
SELECT SUM(S.Sales_Amt)
FROM Sales S
c.
You might also like to view...
Match the following terms to their meanings:
I. Favorite II. Bookmark III. folder IV. Web site V. download A. process that allows one to view a Web page while offline. B. a link saved in Internet Explorer C. a link saved in Firefox D. way of organizing links E. group of related Web pages
Unbound controls do not require data entry so a tab stop can be removed
Indicate whether the statement is true or false