Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 The Oracle PL/SQL GROUPING Function      [Return To Index] Jump to:  
  Looking for the original pages? (formerly called "Morgan's Library") You can find them here.

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      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 201 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?