NTILE

functionsupportedCore SQL functions

docs.snowflake.com ↗

Window function syntax and usage

Divides an ordered data set equally into the number of buckets specified by constant_value. Buckets are sequentially numbered 1 through constant_value.

Syntax

supportedpartialnot supportednot scored

NTILE( <constant_value> ) OVER ( [ PARTITION BY <expr1> ]
  ORDER BY <expr2> [ { ASC | DESC } ] [ NULLS { FIRST | LAST } ] )

Parameters

NameRequiredDescription
constant_valuerequiredThe desired number of buckets; must be a positive integer value.
expr1requiredIf you wish to partition the data into groups, specify the criterion (usually a column) to partition by. For example, you might partition by province.
expr2requiredThe expression (usually a column) by which to order the rows in the window. For example, you might order by timestamp.

Usage notes