Pular para o conteúdo

Indica se uma coluna especificada em uma cláusula GROUP BY está agregada. Retorna 1 se estiver agregada e 0 caso contrário.

func.grouping(get_column(table, 'department'))
func.grouping(get_column(table, 'department'))
GROUPING(<department>)
SELECT department, GROUPING(department), SUM(salary)
FROM employees GROUP BY ROLLUP(department);
┌────────────┬───────────────────────┬─────────────┐
│ department │ grouping(department) │ sum(salary) │
├────────────┼───────────────────────┼─────────────┤
│ Sales │ 0 │ 195000 │
│ IT │ 0 │ 246000 │
│ NULL │ 1 │ 441000 │
└────────────┴───────────────────────┴─────────────┘