Management & CommerceVery hardMBA Placement · Data Analyst · SQL test

sales(region, product, amt) contains these region–product combinations: North–A, North–B, South–A, South–B, South–C and East–A (several rows each). How many rows does SELECT region, product, SUM(amt) FROM sales GROUP BY ROLLUP(region, product) return?

  1. A. 13
  2. B. 9
  3. C. 10
  4. D. 7

Correct answer: C. 10

ROLLUP(region, product) gives the 6 detail groups, 3 region subtotals (product NULL) and 1 grand total: 10. CUBE would add 3 product subtotals for 13; 9 forgets the grand total.

More Operations, Supply Chain & Business Analytics questions

Exams that ask this topic