RowNumber function

The RowNumber function returns the sequential number of a row within a partition of a result set, starting at 1 for the first row in each partition. It is available for all data types.

Row_Number and Rank are similar. Row_Number numbers all rows sequentially (for example 1, 2, 3, 4, 5). Rank provides the same numeric value for ties (for example 1, 2, 2, 4, 5).

This function requires also using the OrderBy() function. The PartitionBy() function is optional. If PartitionBy() is used with OrderBy(), OrderBy() must appear after PartitionBy().

<table>.<field>.Row_Number.PartitionBy(<table>.<field>).OrderBy(<table>.<field>)

Example:

Last modified: Friday May 12, 2023

Is this useful?