ROW_NUMBER
This section contains reference documentation for the ROW_NUMBER function.
Signature
ROW_NUMBER examples
Order transactions by payment date
select customer_id, payment_date, amount, ROW_NUMBER() OVER(ORDER BY payment_date from payment;
customer_id
payment_date
amount
row_number
1
2
3
4
5
6
7
8
9
10
Identify the top two transactions by customer, ordered by transaction amount
row_number
customer_id
payment_date
amount
9.99
7.99
10.99
8.99
8.99
10.99
10.99
10.99
Identify customers with the highest number of transactions
customer_id
count
row_number
Was this helpful?

