FirebirdSQL logo

NTILE()

Distributes the rows of the current window partition into the specified number of tiles (groups)

Result type

BIGINT

Syntax
NTILE ( number_of_tiles ) OVER <window_name_or_spec>
Table 1. Arguments of NTILE
Argument Description

number_of_tiles

Number of tiles (groups).Restricted to a positive integer literal, a named parameter (PSQL), or a positional parameter (DSQL).

NTILE Examples

select
  id,
  salary,
  rank() over (order by salary),
  ntile(3) over (order by salary)
from employee
order by salary;
Result
ID SALARY RANK NTILE
== ====== ==== =====
 3   8.00    1     1
 4   9.00    2     1
 1  10.00    3     2
 5  10.00    3     2
 2  12.00    5     3