Bird
0
0

What is wrong with this SQL query?

medium📝 Debug Q6 of 15
SQL - Advanced Window Functions
What is wrong with this SQL query?
SELECT user_id, LEAD(score) FROM GameResults ORDER BY user_id;
ALEAD cannot be used with numeric columns
BORDER BY cannot be used in SELECT statements
CLEAD function is missing an OVER() clause
Duser_id must be included inside LEAD()
Step-by-Step Solution
Solution:
  1. Step 1: Check LEAD usage

    The LEAD function requires an OVER() clause to specify the window for row access.
  2. Step 2: Analyze the query

    The query uses LEAD(score) without OVER(), which is invalid syntax.
  3. Step 3: Validate other options

    ORDER BY is valid at the end of the query. LEAD works with numeric columns. user_id does not need to be inside LEAD.
  4. Final Answer:

    LEAD function is missing an OVER() clause -> Option C
  5. Quick Check:

    LEAD requires OVER() clause [OK]
Quick Trick: LEAD must always have OVER() clause [OK]
Common Mistakes:
  • Forgetting OVER() with LEAD
  • Misplacing ORDER BY clause
  • Assuming LEAD needs column inside

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes