This function assigns a row id to each row returned by the sql query fired. It provides distinct row id to distinct values, similar values have similar row id, the next row id is calculated as number of occurrence of previous row id + 1 i.e it leaves gaps between groups.
This function also provides a row id to each row returned by the sql query fired therefore is similar to Rank() function with only difference, this will not leave gaps between groups.
Example demonstrating difference between above two function:
Decalring a table variable and inserting values into it: