Bird
0
0

If you use NTILE(4) on 10 rows, how many rows will be in the first bucket?

easy📝 Conceptual Q2 of 15
PostgreSQL - Window Functions in PostgreSQL
If you use NTILE(4) on 10 rows, how many rows will be in the first bucket?
A2
B5
C4
D3
Step-by-Step Solution
Solution:
  1. Step 1: Calculate base size per bucket

    10 rows divided by 4 buckets gives 2 rows per bucket with 2 extra rows to distribute.
  2. Step 2: Distribute extra rows to first buckets

    The first 2 buckets get 3 rows each, the last 2 get 2 rows each.
  3. Final Answer:

    3 -> Option D
  4. Quick Check:

    NTILE distributes extra rows starting from first bucket [OK]
Quick Trick: Extra rows go to first buckets when dividing with NTILE [OK]
Common Mistakes:
  • Assuming all buckets have exactly equal rows
  • Ignoring leftover rows when dividing

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes