GATE DA 2025, Q.46: Rows produced by CUBE on two dimensions
The question
Facts(D1, D2, val): D1 has 3 values, D2 has 2, and all 6 combinations are present. How many tuples does SELECT D1, D2, sum(val) FROM Facts GROUP BY CUBE(D1, D2) return?
- (A) 1
- (B) 6
- (C) 9
- (D) 12
Watch it solved
Solve it step by step
- CUBE. Groups by every subset of {D1, D2}.
- Count each. (D1, D2): 6. (D1): 3. (D2): 2. (): 1.
- Total. 6 + 3 + 2 + 1 = 12.
Answer: (D) 12
Official IIT Roorkee answer key: D.
Common mistake. Counting only the full grouping (6) or forgetting the grand total row.
Remember. CUBE over k dimensions = 2ᵏ groupings; rows = Π (nᵢ + 1).
Want every question solved? The past-paper pack has all 195 questions from 2024, 2025 and 2026 for ₹499. The cheat sheet pack has 23 printable sheets for ₹399.
See the past-paper pack See the cheat sheetsSource: official GATE DA 2025 question paper and answer key (IIT Roorkee). The question is lightly reworded; every number and option is kept.