NTILE

NTILE(n) splits the ordered rows of a window into n buckets of nearly equal size and returns the bucket number. It is used to form quartiles, deciles or customer segments. When the number of rows is not divisible by n, the first buckets get one extra row.

Example

NTILE(4) OVER (ORDER BY ca DESC)

Related concepts

The whole glossary