Bird
0
0

Which of the following is the correct syntax to assign quartiles using NTILE?

easy📝 Syntax Q3 of 15
SQL - Window Functions Fundamentals

Which of the following is the correct syntax to assign quartiles using NTILE?

ASELECT column, NTILE(4) PARTITION BY column FROM table;
BSELECT column, NTILE(4) FROM table ORDER BY column;
CSELECT column, NTILE(4) OVER (ORDER BY column) AS quartile FROM table;
DSELECT column, NTILE OVER (4 ORDER BY column) AS quartile FROM table;
Step-by-Step Solution
Solution:
  1. Step 1: Recall NTILE syntax

    NTILE requires a number and an OVER clause with ORDER BY to define row order.
  2. Step 2: Check each option

    SELECT column, NTILE(4) OVER (ORDER BY column) AS quartile FROM table; correctly uses NTILE(4) OVER (ORDER BY column). Others have syntax errors or missing OVER clause.
  3. Final Answer:

    SELECT column, NTILE(4) OVER (ORDER BY column) AS quartile FROM table; -> Option C
  4. Quick Check:

    NTILE syntax = NTILE(n) OVER (ORDER BY col) [OK]
Quick Trick: NTILE needs OVER with ORDER BY to work [OK]
Common Mistakes:
  • Omitting OVER clause
  • Placing PARTITION BY incorrectly
  • Misordering NTILE parameters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes