How to Use the Grouping Function
grouping function returns a value of 1 when a grand total for groups is displayed on a
group by clause with the
rollup function. Otheriwse, the
grouping function will return a 0. Therefore, this function allows you to distinguish a group total from a
grand total for multiple groups.
To learn how to use the
grouping function, follow these steps:
- You'll need to download and install Oracle 12c. The instructions for the setup can be found in How to use sample schemas. Follow steps 1 through 4 before proceeding to the next step.
- The following query uses the
groupingfunction to display the value of the function on group total lines and on the final overall count:
Note that the value of the function is 0 on group total report lines and is 1 on the final aggregate total of all groups printed at the end of the report.