Bird
0
0

Identify the error in this query:

medium📝 Debug Q6 of 15
SQL - Advanced Window Functions
Identify the error in this query:
SELECT id, amount, SUM(amount) OVER ORDER BY date AS running_total FROM sales;
AMissing GROUP BY clause
BMissing parentheses after OVER
CSUM() cannot be used with OVER
DORDER BY cannot be used inside OVER
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax of window function

    OVER clause must have parentheses even if empty or with ORDER BY inside.
  2. Step 2: Identify missing parentheses

    Query has OVER ORDER BY without parentheses, which is invalid syntax.
  3. Final Answer:

    Missing parentheses after OVER -> Option B
  4. Quick Check:

    OVER() requires parentheses [OK]
Quick Trick: Always use parentheses after OVER, even with ORDER BY [OK]
Common Mistakes:
  • Omitting parentheses after OVER
  • Placing ORDER BY outside OVER
  • Confusing GROUP BY with window functions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes