GROUPING
Shows whether a row is a ROLLUP or CUBE subtotal for a column: 1 — a subtotal, 0 — an ordinary group.
Syntax
GROUPING(<column>)
GROUPING(<column1>, <column2>, …)
ROLLUP adds subtotal rows to a report, where the grouping column becomes NULL. But NULL can also be a real value, so it can't tell a subtotal from a “no department” group. GROUPING gives 1 precisely for the subtotal row — that's what you use to label it “Total”.