MSSQLAggregate FunctionsGROUPING
CHECKSUM_AGG

GROUPINGAggregate Functions

GROUPING_ID

Returns whether a row is aggregated by ROLLUP/CUBE.

Syntax

GROUPING(expr)

Example

Enter values below to update the example in real time.

department_id
job_id
salary
total
grp_dept
employees
SELECT department_id, job_id,
       SUM(salary) AS total,
       GROUPING(department_id) AS grp_dept
FROM employees
GROUP BY ROLLUP (department_id, job_id);