What does the following query return? SELECT department, COUNT(*) FROM employees GROUP BY GROUPING SETS ((department), ())

SQL Fundamentals Hard

SQL Fundamentals — Hard

What does the following query return? SELECT department, COUNT(*) FROM employees GROUP BY GROUPING SETS ((department), ())

Key points

  • The query uses GROUPING SETS to specify multiple grouping sets
  • The result includes per-department counts and a total row
  • The empty grouping set () generates the grand total

Ready to go further?

Related questions