Gradient LabSign up free

Home / GATE DA / 2025 / Q.46

GATE DA 2025, Q.46: Rows produced by CUBE on two dimensions

DatabasesGROUP BY CUBE2 marksMCQFree

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?

Watch it solved

Solve it step by step

  1. CUBE. Groups by every subset of {D1, D2}.
  2. Count each. (D1, D2): 6. (D1): 3. (D2): 2. (): 1.
  3. 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 sheets

Source: official GATE DA 2025 question paper and answer key (IIT Roorkee). The question is lightly reworded; every number and option is kept.