Skip to main content

Posts

Showing posts with the label ed

Example of rollup and cube in sql

SQL> SELECT DEPTNO,SUM(SAL)  2 FROM EMP  3 GROUP BY ROLLUP(DEPTNO)  4 /  DEPTNO SUM(SAL) ---------- ----------  10 8750  20 10875  30 9400  29025 SQL> ED Wrote file afiedt.buf  1 SELECT NVL(TO_CHAR(DEPTNO),'TOTAL'),SUM(SAL)  2 FROM EMP  3* GROUP BY ROLLUP(DEPTNO) SQL> / NVL(TO_CHAR(DEPTNO),'TOTAL') SUM(SAL) ---------------------------------------- ---------- 10 8750 20 10875 30 9400 TOTAL 29025 SQL> ED Wrote file afiedt.buf  1 SELECT NVL(TO_CHAR(DEPTNO),'TOTAL'),SUM(SAL)  2 FROM EMP  3* GROUP BY CUBE(DEPTNO) SQL> / NVL(TO_CHAR(DEPTNO),'TOTAL') SUM(SAL) ---------------------------------------- ---------- TOTAL 29025 10 8750 20 10875 30 9400 SQL> ED Wrote file afiedt.buf  1 SELECT NVL(TO_CHAR(DEPTNO),'TOTAL'),JOB,SUM(SAL)  2 FROM EMP  3* GROUP BY ROLLUP(DEPTNO,JOB) SQL> / NVL(TO_CHAR(DEPTNO),'TOTAL') JOB SUM(SAL) ---------------------------------------- --------- ----------...