September 2010
Intermediate to advanced
1704 pages
111h 8m
English
NTILE FunctionThe NTILE function assigns a ranking value by separating the result rows of a query into a specified number of approximately even-sized groups. Each group of rows is assigned the same ranking number, starting with 1 for the first group, 2 for the second, and so on. You specify the number of groups you want the result set divided into as the argument to the NTILE function. The number of rows in a group is determined by dividing the total number of rows in the result set by the number of groups. If there’s a remainder, n, the first n groups have an additional row assigned to them. Listing 43.48 provides an example of using the NTILE function, so you can compare it to the ROW_NUMBER function.
Listing 43.48 Using the NTILE Function ...