Ntile
Definition
The ntile
method allows you to add the NTILE
function to the query. The NTILE
function allows you to divide ordered rows in the partition into a specified number of ranked groups as equal size as possible. These ranked groups are called buckets.
Available methods
ntile(int buckets)
: Receives buckets value which will be supplied to theNTILE
function.
To use this way, you need to import the static functions as follows:
import static com.myzlab.k.KFunction.*;
Example
Java code:
k
.select(
APP_USER.FIRST_NAME,
ntile(3).over(wd().orderBy(APP_USER.ID))
)
.from(APP_USER)
.multiple();
SQL generated:
SELECT
au.first_name,
NTILE(3) OVER(ORDER BY au.id)
FROM app_user au
Parameters:
- None