Ranking function syntax are similar for all 4 different type of ranking functions.
Partition: use for group the result set.
- Row Number: Returns the sequential number of a row within a partition of a result set, starting at 1 for the first row in each partition.
- Rank: Returns the rank of each row within the partition of a result set. The rank of a row is one plus the number of ranks that come before the row in question.
- DENSE_RANK: Similer to Rank but without the gap.
- NTILE:Distributes 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.
Because we partition by PSC.Name( Category) therefore you can see the result has been group as many subset group.
Below example divide the result set to 10 groups and then shows which group the row belong to.