Explain the difference between the output produced by SQL ROLLUP and CUBE queries.
What will be an ideal response?
The ROLLUP and CUBE
extensions to GROUP BY generate OLAP-type summaries of the data with subtotals and totals. The
columns to be defined are defined similarly to how grouping sets can define GROUP BY columns.
ROLLUP generates subtotal and total rows for the GROUP BY columns. CUBE extends the
capabilities by generated subtotal rows for every combination of GROUP BY columns. ROLLUP and
CUBE also generate a grand total row.
A simple example of a ROLLUP query is shown below:
SELECT a, b, c, sum(x)
FROM t
GROUP BY ROLLUP (a,b,c)
Produces aggregates of x for (a,b,c), (a,b), a, (grand total)
A simple example of a CUBE query is shown below:
SELECT a, b, c, sum(x)
FROM t
GROUP BY CUBE (a,b,c)
Produces aggregates of x for (a,b,c), (a,b), (a,c), a, (b,c), b, c, (grand total). The rows that are produced
by ROLLUP and CUBE are shown in bold.
You might also like to view...
When an operation is performed on two int values, the result will be a(n) ____________.
a. decimal b. double c. string d. int
In a multi-level bulleted list slide, creating a lower-level paragraph is called ____ the text.
A. demoting B. decreasing C. promoting D. increasing
When you convert text to outlines and apply a gradient fill, the gradient automatically fills each letter individually.
Answer the following statement true (T) or false (F)
Opcodes are represented by abbreviations, called __________ that indicate the operation.
Fill in the blank(s) with the appropriate word(s).