Bird
0
0

Why might NTILE produce uneven bucket sizes when the total number of rows is not divisible by the number of buckets?

hard📝 Conceptual Q10 of 15
PostgreSQL - Window Functions in PostgreSQL
Why might NTILE produce uneven bucket sizes when the total number of rows is not divisible by the number of buckets?
ABecause NTILE always creates empty buckets at the end
BBecause NTILE distributes leftover rows starting from the first bucket
CBecause NTILE ignores leftover rows
DBecause NTILE rounds down bucket sizes to nearest integer
Step-by-Step Solution
Solution:
  1. Step 1: Understand NTILE distribution logic

    When rows don't divide evenly, NTILE adds leftover rows to first buckets.
  2. Step 2: Explain uneven bucket sizes

    This causes some buckets to have one more row than others, starting from bucket 1.
  3. Final Answer:

    Because NTILE distributes leftover rows starting from the first bucket -> Option B
  4. Quick Check:

    Leftover rows go to first buckets in NTILE [OK]
Quick Trick: Leftover rows go to first buckets, causing uneven sizes [OK]
Common Mistakes:
  • Assuming all buckets always have equal rows
  • Thinking NTILE drops leftover rows

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes