NTILE(N) over_clause

Divides a partition into N groups (buckets), assigns each row in the
partition its bucket number, and returns the bucket number of the
current row within its partition. For example, if N is 4, NTILE()
divides rows into four buckets. If N is 100, NTILE() divides rows into
100 buckets.

N must be a literal positive integer. Bucket number return values range
from 1 to N.

Beginning with MySQL 8.0.22, N cannot be NULL, and must be an integer
in the range 0 to 263, inclusive, in any of the following forms:

o an unsigned integer constant literal

o a positional parameter marker (?)

o a user-defined variable

o a local variable in a stored routine

This function should be used with ORDER BY to sort partition rows into
the desired order.

over_clause is as described in
https://dev.mysql.com/doc/refman/8.0/en/window-functions-usage.html.

URL: https://dev.mysql.com/doc/refman/8.0/en/window-function-descriptions.html

