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

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 |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org