The SQL GROUPING is one of the Aggregate Functions, which is useful to indicate whether the specified column in a GROUP BY Clause is aggregated or not. This Grouping function will return one for aggregated and zero for not aggregated.
The basic syntax behind this aggregate Grouping function is as shown below:
SELECT GROUPING ([Column_Name]) FROM [Source] GROUP BY [Column_Name]
For this grouping function example, we are going to use the [MyEmployee table] and it has 14 records.

SQL Grouping Function Example
The Grouping function returns whether the grouping on the defined column has happened or not, by returning 0 and 1. In this grouping function example, we will show you the same.
SELECT [Education] ,[Occupation] ,GROUPING([Occupation]) AS 'Grouping' ,GROUPING([Education]) AS 'Grouping 2' ,SUM([YearlyIncome]) as income FROM [MyEmployees Table] GROUP BY [Education] ,[Occupation] WITH ROLLUP
The following Aggregate Function statements check whether the Grouping performed on the Education, and Occupation columns are not by returning 1 and 0. Please refer to the GROUP BY Clause to understand the SQL Server Grouping techniques.
,GROUPING([Occupation]) AS 'Grouping' ,GROUPING([Education]) AS 'Grouping 2'