Quick Search:
 
 The Oracle PL/SQL GROUPING Function      [Return To Index] Jump to:  

Term: GROUPING

Definition:
The Oracle PL/SQL GROUPING function is used to identify the final aggregated rows in grouped rows using ROLLUP and CUBE extension clauses. It returns numeric values to identify the column value in an aggregated row. If it is NOT NULL, it returns zero, otherwise for NULL values of the column, it returns 1.

With the GROUPING function you can distinguish a NULL representing the set of all values in a superaggregate row from a NULL in a regular row.

Note that the expression in the GROUPING function must match one of the expressions in the GROUP_BY clause.

Example Syntax:

GROUPING (Column)


Example Usage:

SELECT DECODE(GROUPING(DEPTNO), 1, 'All Departments', DEPTNO) AS  DEPT,  SUM(SALARY)
FROM EMPLOYEES
GROUP_BY ROLLUP(DEPTNO);


Related Links:
 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org