Bird
0
0

Identify the error in this query:

medium📝 Debug Q6 of 15
PostgreSQL - Aggregate Functions and GROUP BY
Identify the error in this query:
SELECT region, product, SUM(amount) FROM sales GROUP BY ROLLUP region, product;
AROLLUP cannot be used with text columns
BSUM() cannot be used with ROLLUP
CGROUP BY cannot include multiple columns
DMissing parentheses around columns in ROLLUP
Step-by-Step Solution
Solution:
  1. Step 1: Check ROLLUP syntax

    ROLLUP requires parentheses around the list of columns: ROLLUP(column1, column2).
  2. Step 2: Identify error in query

    The query misses parentheses around region and product inside ROLLUP, causing syntax error.
  3. Final Answer:

    Missing parentheses around columns in ROLLUP -> Option D
  4. Quick Check:

    ROLLUP syntax needs parentheses [OK]
Quick Trick: Always use parentheses with ROLLUP columns [OK]
Common Mistakes:
  • Omitting parentheses in ROLLUP
  • Misunderstanding aggregate function usage
  • Thinking ROLLUP restricts column types

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes