ROLLUP enables an SQL statement to calculate subtotals across groups of dimensions and a grand total by using a simple extension to the GROUP BY clause. CUBE enables a SELECT statement to calculate subtotals for all possible combinations of dimensions and a grand total, allowing a cross-tabular report to be generated with a single statement by grouping on CUBE. In an example, ROLLUP and CUBE are used to group employee data by department and job to produce subtotals for each as well as grand totals.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
51 views1 page
Select Deptno, Job, Count ( ), Sum (Sal) From Emp
ROLLUP enables an SQL statement to calculate subtotals across groups of dimensions and a grand total by using a simple extension to the GROUP BY clause. CUBE enables a SELECT statement to calculate subtotals for all possible combinations of dimensions and a grand total, allowing a cross-tabular report to be generated with a single statement by grouping on CUBE. In an example, ROLLUP and CUBE are used to group employee data by department and job to produce subtotals for each as well as grand totals.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1
ROLLUP enables an SQL statement to calculate multiple levels of subtotals across
a specified group of dimensions. It also calculates a grand total. ROLLUP is a
simple extension to the GROUP BY clause, so its syntax is extremely easy to use. SELECT deptno, job, count(*), sum(sal) FROM emp GROUP BY ROLLUP(deptno,job);
In multidimensional jargon, a cube is a cross-tabulated summary of detail rows.
CUBE enables a SELECT statement to calculate subtotals for all possible combinations of a group of dimensions. It also calculates a grand total. This is the set of information typically needed for all cross-tabular reports, so CUBE can calculate a cross-tabular report with a single select statement. Note in the example below that totals are calculated for each department, and also for each job category. SELECT deptno, job, count(*), sum(sal) FROM emp GROUP BY CUBE(deptno,job);