$ ./guess_the_languageSQL & Databases
SQL & Databases · medium · #18

How many rows does this return?

-- PostgreSQL; sales has regions EU, US, APAC
SELECT region, SUM(total)
FROM sales
GROUP BY ROLLUP (region);
  1. 6
  2. 4
  3. 1
  4. 3
ROLLUP adds a grand-total row (region NULL) after the three per-region rows.
Play SQL & Databases ▸