Bird
0
0

Given the table sales with amount values: 10, 20, 30, 40, 50, what is the ntile(3) value for the row with amount = 40 when ordered by amount?

medium📝 query result Q13 of 15
SQL - Window Functions Fundamentals

Given the table sales with amount values: 10, 20, 30, 40, 50, what is the ntile(3) value for the row with amount = 40 when ordered by amount?

SELECT amount, NTILE(3) OVER (ORDER BY amount) AS tile FROM sales;
A2
B1
C3
D4
Step-by-Step Solution
Solution:
  1. Step 1: Order amounts and assign NTILE(3)

    Sorted amounts: 10, 20, 30, 40, 50. NTILE(3) splits 5 rows into 3 groups: first 2 rows in tile 1, next 2 in tile 2, last 1 in tile 3.
  2. Step 2: Find tile for amount 40

    Amount 40 is the 4th row, which falls in tile 2.
  3. Final Answer:

    2 -> Option A
  4. Quick Check:

    Row 4 in 3 groups = tile 2 [OK]
Quick Trick: Divide rows evenly; count position to find tile [OK]
Common Mistakes:
  • Assuming equal group sizes always
  • Assigning tile 3 to amount 40 incorrectly
  • Confusing row position with tile number

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes