The following questions are designed to reinforce key information presented in the appendix. If you are unable to answer a question, review the appropriate lesson and then try the question again.
The GROUP BY clause with the CUBE operator provides the most complete data.
The GROUP BY clause provides only one level of summaries (or groups).
The ROLLUP operator provides summaries for some categories.
The CUBE operator provides summaries for all categories.
You also could use the COMPUTE or COMPUTE BY clauses to generate basic reports.
No. The COMPUTE and COMPUTE BY clauses generate extra summary rows of data in a nonrelational format. Although it is useful for viewing, the output is not well suited for generating result sets to use with other applications. You could use the GROUP BY clause and the CUBE or ROLLUP operator to provide data in a standard relational format that other clients can use easily.
Use the GROUPING function on the columns that allow null values. A value of 1 appears in the column generated by the GROUPING function if that row is a summary row.
Yes. You can use the SELECT TOP n [PERCENT] statement to answer each question. The first question would be answered with the SELECT TOP 100...ORDER BY...DESC statement so that the items with the highest quantity that are sold would be at the top of the list.
The second question would be answered with the SELECT TOP 5 PERCENT...ORDER BY...ASC statement so that the items with the lowest quantity that are sold would be at the top of the list.
Another way to answer these questions is to set the number of rows that are returned by the query using the SET ROWCOUNT option.