The GROUP BY CUBE clause produces a subtotal line for each department number, and calculates a total for each job in each department, a grand total at the end of the query, and a total for each job in the following example. The GROUP BY ROLLUP does not return the totals for each job, but does return everything else like the GROUP BY CUBE.
SQL> SELECT DEPTNO, JOB, COUNT(*)
FROMEMP
GROUP BY CUBE(DEPTNO,JOB);
DEPTNO JOB COUNT(*)
---------------------------
10 CLERK 1
10 MANAGER 1
10 PRESIDENT 1
10 3
20 ANALYST 2
20 CLERK 2
20 MANAGER 1
For More details you can follow: https://oracle-base.com/articles/misc/rollup-cube-grouping-functions-and-grouping-sets