Bird
0
0

Identify the error in this query using NTILE:

medium📝 Debug Q14 of 15
SQL - Window Functions Fundamentals

Identify the error in this query using NTILE:

SELECT id, NTILE(0) OVER (ORDER BY score) AS group_num FROM players;
ANTILE requires PARTITION BY clause.
BNTILE cannot have 0 as argument; it must be a positive integer.
CORDER BY clause is missing inside OVER().
DThe alias <code>group_num</code> is not allowed.
Step-by-Step Solution
Solution:
  1. Step 1: Check NTILE argument validity

    NTILE requires a positive integer greater than zero to define groups.
  2. Step 2: Analyze the query

    NTILE(0) is invalid and causes an error; ORDER BY is present, PARTITION BY is optional, alias is valid.
  3. Final Answer:

    NTILE cannot have 0 as argument; it must be a positive integer. -> Option B
  4. Quick Check:

    NTILE argument > 0 required = NTILE cannot have 0 as argument; it must be a positive integer. [OK]
Quick Trick: NTILE argument must be positive integer > 0 [OK]
Common Mistakes:
  • Using zero or negative numbers in NTILE
  • Thinking PARTITION BY is mandatory
  • Confusing alias rules

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes