ROLLUP in Oracle

ROLLUP will provide the functional result to each group and entire aggragation of functional result of all groups. ROLLUP is a simple extension to the GROUP BY clause, so its syntax is extremely easy to use. The ROLLUP extension is highly efficient, adding minimal overhead to a query.
For n number of columns in the ROLLUP list, n+1 number of result sets will be produced.

Without ROLLUP:
SELECT PRODUCT_ID, YEAR, SUM(PRICE)
FROM SALES
GROUP BY PRODUCT_ID, YEAR
ORDER BY PRODUCT_ID, YEAR;

PRODUCT_IDYEARSUM(PRICE)
10020105000
10020115000
10020125000
20020109000
20020119000
20020129000
30020107000
30020117000
30020127000
30020137000

With ROLLUP:
SELECT PRODUCT_ID, YEAR, SUM(PRICE)
FROM SALES
GROUP BY ROLLUP(PRODUCT_ID, YEAR)
ORDER BY PRODUCT_ID, YEAR;

PRODUCT_IDYEARSUM(PRICE)
10020105000
10020115000
10020125000
100<null>15000
20020109000
20020119000
20020129000
200<null>27000
30020107000
30020117000
30020127000
30020137000
300<null>28000
<null><null>70000

Partial rollup:
ROLLUP is defined partially in the GROUP BY clause.
SELECT PRODUCT_ID, YEAR, SUM(PRICE)
FROM SALES
GROUP BY PRODUCT_ID, ROLLUP(YEAR)
ORDER BY PRODUCT_ID, YEAR;


PRODUCT_IDYEARSUM(PRICE)
10020105000
10020115000
10020125000
100<null>15000
20020109000
20020119000
20020129000
200<null>27000
30020107000
30020117000
30020127000
30020137000
300<null>28000

In the above example, rollup summary is available for every group but not with the grand total since its defined only for year.