People are capable of all kinds of good thinking, but some just don't see what's right in front of their noses.
Home
 

NTILE() in Transact-SQL

This function is used to distribute the rows in an ordered partition into a specified number of groups. The groups are numbered, starting at one. For each row, NTILE returns the number of the group to which the row belongs.

Syntax

NTILE (integer_expression) OVER ( [ <partition_by_clause> ] < order_by_clause > )

Arguments


integer_expression
Is a positive integer constant expression that specifies the number of groups into which each partition must be divided. integer_expression can be of type int, or bigint.
<partition_by_clause>
Divides the result set produced by the FROM clause into partitions to which the function is applied. For the PARTITION BY syntax, see OVER Clause (Transact-SQL).
<order_by_clause>
Determines the order in which the NTILE values are assigned to the rows in a partition. An integer cannot represent a column when the <order_by_clause> is used in a ranking function.

July 1, 2013 This post was written by Categories: ITSQL No comments yet


Leave a Reply

Top