This page is a quick reference checkpoint for NTILE in IBM DB2: behavior, syntax rules, edge cases, and a minimal example; plus the official vendor documentation.
NTILE divides the rows into a specified number of buckets and assigns each row a bucket number.
Distributes rows into n groups of equal size or as equal as possible; tile numbers start at 1 and increase with ordering; must be used with an ORDER BY clause in the OLAP specification.
If this behavior feels unintuitive, the tutorial below explains the underlying pattern step-by-step.
NTILE(n) assigns each row to one of n tiles; requires ORDER BY within the window specification.
SELECT NTILE(4) OVER (PARTITION BY department ORDER BY salary) FROM employee;
If you came here to confirm syntax, you’re done. If you came here to get better at window functions, choose your next step.
NTILE is part of a bigger window-function pattern. If you want the “why”, start here: Percentile Distribution
Reading docs is useful. Writing the query correctly under pressure is the skill.
For the authoritative spec, use the vendor docs. This page is the fast “sanity check”.
View IBM DB2 Documentation →Looking for more functions across all SQL dialects? Visit the full SQL Dialects & Window Functions Documentation.