That's correct! The last function we'll introduce in this section is
NTILE(X). It distributes the rows into a set number of groups, which is specified by X. For instance:
NTILE(3) OVER(ORDER BY EditorRating DESC) AS GroupNo
In the above example,
NTILE(3) creates three groups based on the values in the column
EditorRating. The "best" games will be put in group 1, the "average" games in group 2, and the "worst" games in group 3. See the picture below:
A note about
NTILE(): if the number of rows is not divisible by the number of groups, some groups will have one more element than others. Larger groups will be listed first.