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

Term: GROUPING_ID

Definition:
The Oracle PL/SQL GROUPING_ID function works as an extension of the GROUPING function. Unlike GROUPING, GROUPING_ID distinguishes entire rows from each other. It accepts one or more columns and returns the decimal equivalent of the GROUPING bit vector, which is just the combination of results from GROUPING function for each column specified.

Row filtering is made simpler with this function because the rows that are sought can be identified with a single condition of GROUPING_ID = n. GROUPING_ID tells you the level of aggregation.

GROUPING_ID is extremely useful for determining the summarization of Multiple columns. It returns a decimal number which, when converted to binary, is a concatenation of the 1's and 0's which represent the summarization flag of each column passed into the GROUPING_ID function.

Example Syntax:

GROUPING_ID (columns)


Example Usage:

SELECT DEPTNO, JOB_ID, 
GROUPING (DEPTNO),
GROUPING (JOB_ID),
GROUPING_ID (DEPTNO, JOB_ID),
SUM(SALARY)
FROM EMPLOYEES
GROUP_BY CUBE


Related Links:
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 327 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?