1SELECT row_number() over ( order by firstName) RowNumberSqeuence,FirstName from rowNumberDemo
2 order by FirstName;
1
2
3
4
5 set @row_number := 0;
6
7SELECT
8 @row_number:=CASE
9 WHEN @customer_no = customerNumber
10 THEN @row_number + 1
11 ELSE 1
12 END AS num,
13 @customer_no:=customerNumber customerNumber,
14 paymentDate,
15 amount
16FROM
17 payments
18ORDER BY customerNumber;
1SET @row_number = 0;
2SELECT
3 (@row_number:=@row_number + 1) AS num,
4 firstName,
5 lastName
6FROM
7 employees
8ORDER BY firstName, lastName
9LIMIT 5;