Bird
0
0

Identify the error in this query:

medium📝 Debug Q6 of 15
SQL - Window Functions Fundamentals
Identify the error in this query:
SELECT id, amount, SUM(amount) PARTITION BY region FROM sales;
ASUM() cannot be used in SELECT
BPARTITION BY cannot be used with SUM()
CMissing GROUP BY clause
DMissing OVER() clause after SUM(amount)
Step-by-Step Solution
Solution:
  1. Step 1: Check window function syntax

    Window functions require OVER() clause to specify partitioning or ordering.
  2. Step 2: Identify missing OVER()

    The query uses PARTITION BY without OVER(), which causes syntax error.
  3. Final Answer:

    Missing OVER() clause after SUM(amount) -> Option D
  4. Quick Check:

    Window functions need OVER() [OK]
Quick Trick: Always use OVER() with window functions [OK]
Common Mistakes:
  • Omitting OVER() clause
  • Confusing PARTITION BY with GROUP BY
  • Thinking SUM() can't be in SELECT

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes