ROW_NUMBER … OVER … PARTITION BY

Use the ROW_NUMBER function to number the result set. If a partition is used, the row number of the row within the partition is returned. Use ORDER BY to sort the results.

Syntax

ROW_NUMBER ( ) over ( [ PARTITION BY value_expression1, value_expression2,  … ] order by …)