top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the use of CUBE in Oracle?

+1 vote
325 views
What is the use of CUBE in Oracle?
posted Aug 13, 2015 by Viswas Kumar

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

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

answer Aug 16, 2015 by Amit Kumar Pandey
Similar Questions
+3 votes

What is the difference between rollup and cupe, which is good to use also give example to solve?
Also if someone can explain about what is grouping function?

...