The Oracle GROUP_ID function uniquely identifies a group of rows which has been created by GROUP BY clause in the query result set. It generates a number for a group to distinguish the duplicate groups. For 'n' duplicate groups, GROUP_ID can attain value from 0 to n-1 to number the groups.
Note that the function does not accept any parameters and these numbers are unique for each set of duplicate groups.
The GROUP_ID function is usable only in a SELECT statement that contains a GROUP_BY clause.
A unique group is assigned zero, while duplicate groups (if any) are assigned values greater than zero.
SELECT DEPTNO, JOB_ID, COUNT(*), GROUP_ID ()
GROUP_BY DEPTNO, ROLLUP(DEPTNO, JOB_ID)