Divide rows in a window partition into a specified number of ranked buckets (tiles) as evenly as possible, returning the bucket number for each row.
Divides rows into N roughly equal groups and assigns a bucket number (1 to N) to each row. Useful for creating quartile, quintile, or decile buckets for analysis and bucketed sampling.
| Database System | Support Status | Since Version | Notes |
|---|---|---|---|
| MySQL | ✓ Supported | 8.0 | NTILE(n) added in MySQL 8.0. Distributes rows into n buckets. If rows don't divide evenly, earlier buckets get one extra row. NTILE(100) = percentile bucket. |
| PostgreSQL | ✓ Supported | 8.4 | Standard NTILE(n). Supports the WINDOW clause shorthand for reusing window definitions. |
| SQL Server | ✓ Supported | 2005 | Standard NTILE(n). Available since SQL Server 2005. |
| Oracle | ✓ Supported | 8i | Standard NTILE(n). Available since 8i. |
| SQLite | ✓ Supported | 3.25.0 | NTILE(n) added in SQLite 3.25.0. |
NTILE is universally supported across all engines (post MySQL 8.0). The bucket distribution rule for uneven splits is consistent: earlier buckets get the extra row. NTILE(100) gives approximate percentile buckets; for true percentiles use PERCENTILE_CONT() WITHIN GROUP.
NTILE(n) added in MySQL 8.0. Distributes rows into n buckets. If rows don't divide evenly, earlier buckets get one extra row. NTILE(100) = percentile bucket.
Standard NTILE(n). Supports the WINDOW clause shorthand for reusing window definitions.
Standard NTILE(n). Available since SQL Server 2005.
Standard NTILE(n). Available since 8i.
NTILE(n) added in SQLite 3.25.0.