Bird
0
0

Identify the error in this query using CUBE:

medium📝 Debug Q14 of 15
PostgreSQL - Aggregate Functions and GROUP BY
Identify the error in this query using CUBE:
SELECT region, product, SUM(amount) FROM sales GROUP BY CUBE region, product;
AGROUP BY cannot use CUBE with more than one column.
BSUM(amount) cannot be used with CUBE.
CMissing parentheses around columns in CUBE function.
Dregion and product must be in ORDER BY, not GROUP BY.
Step-by-Step Solution
Solution:
  1. Step 1: Check CUBE syntax

    CUBE requires parentheses around the columns: CUBE(region, product).
  2. Step 2: Validate other parts

    SUM(amount) is valid, multiple columns allowed, ORDER BY is unrelated.
  3. Final Answer:

    Missing parentheses around columns in CUBE function. -> Option C
  4. Quick Check:

    CUBE syntax needs parentheses [OK]
Quick Trick: Always use parentheses with CUBE columns [OK]
Common Mistakes:
  • Omitting parentheses in CUBE
  • Thinking SUM is invalid with CUBE
  • Confusing GROUP BY and ORDER BY

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes