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.
SELECT DEPTNO, JOB_ID,
GROUPING_ID (DEPTNO, JOB_ID),