Bird
0
0

Identify the syntax error in this query:

medium📝 Debug Q6 of 15
SQL - Window Functions Fundamentals
Identify the syntax error in this query:
SELECT id, ROW_NUMBER() PARTITION BY category ORDER BY price FROM products;
AIncorrect use of SELECT keyword
BMissing OVER() clause around PARTITION BY and ORDER BY
CORDER BY cannot be used with ROW_NUMBER()
DPARTITION BY should come after FROM clause
Step-by-Step Solution
Solution:
  1. Step 1: Check ROW_NUMBER() syntax

    The ROW_NUMBER() function requires an OVER() clause enclosing PARTITION BY and ORDER BY.
  2. Step 2: Identify error

    The query misses the OVER() keyword, causing a syntax error.
  3. Final Answer:

    Missing OVER() clause around PARTITION BY and ORDER BY -> Option B
  4. Quick Check:

    ROW_NUMBER() must have OVER() [OK]
Quick Trick: ROW_NUMBER() always needs OVER() clause [OK]
Common Mistakes:
  • Omitting OVER() when using PARTITION BY or ORDER BY
  • Placing PARTITION BY outside OVER()
  • Using ORDER BY without OVER()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes