WINDOW FUNCTION ROW_NUMBER

description

Returns a continuously increasing integer starting from 1 for each row of each Partition. Unlike RANK() and DENSE_RANK(), the value returned by ROW_NUMBER() does not repeat or appear vacant, and is continuously incremented.

1. ROW_NUMBER() OVER(partition_by_clause order_by_clause)

example

1. select x, y, row_number() over(partition by x order by y) as rank from int_t;

3. | x | y    | rank     |
4. |---|------|----------|
5. | 1 | 1    | 1        |
6. | 1 | 2    | 2        |
7. | 1 | 2    | 3        |
8. | 2 | 1    | 1        |
9. | 2 | 2    | 2        |
10. | 2 | 3    | 3        |
11. | 3 | 1    | 1        |
12. | 3 | 1    | 2        |
13. | 3 | 2    | 3        |

keywords

1. WINDOW,FUNCTION,ROW_NUMBER