Pages

Monday, November 30, 2009

Rollup Vs Cube

Rollup

Cube

1

The ROLLUP operator is useful for generating reports that contain subtotals and totals

The Cube operator is useful for generating reports that contain totals

2

ROLLUP generates a result set showing aggregates for a hierarchy of values in the selected columns.

CUBE generates a result set showing aggregates for all combinations of values in the selected columns.

3

Example :

SELECT DEPTNO,JOB,SUM(SALARY)

FROM EMPLOYEES

GROUP BY DEPTNO,JOB

WITH ROLLUP

It will give u total and subtotal of all department as well as job.

Example :

SELECT DEPTNO,JOB,SUM(SALARY)

FROM EMPLOYEES

GROUP BY DEPTNO,JOB

WITH CUBE

It will give u total of all departments.

0 comments:

Post a Comment