Bird
0
0

Identify the syntax error in this query:

medium📝 Debug Q6 of 15
SQL - Advanced Window Functions
Identify the syntax error in this query:
SELECT product, amount, amount / SUM(amount) PARTITION BY product OVER () AS pct_total FROM sales;
AThe PARTITION BY clause must be inside the OVER() parentheses
BSUM() cannot be used with PARTITION BY
CThe division operator is misplaced
DOVER() cannot be empty
Step-by-Step Solution
Solution:
  1. Step 1: Understand window function syntax

    PARTITION BY must be inside the OVER() clause.
  2. Step 2: Analyze the query

    Query incorrectly places PARTITION BY before OVER().
  3. Step 3: Correct syntax example

    SUM(amount) OVER (PARTITION BY product)
  4. Final Answer:

    Option A -> Option A
  5. Quick Check:

    PARTITION BY goes inside OVER() [OK]
Quick Trick: PARTITION BY inside OVER() parentheses [OK]
Common Mistakes:
  • Placing PARTITION BY outside OVER()
  • Omitting OVER() entirely
  • Misordering clauses

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes