Answers for "Mysql - How to get a row number after Order by?"

PHP
1

get row number in mysql 5.5

set @row_number := 0;

SELECT 
    @row_number:=CASE
        WHEN @customer_no = customerNumber 
			THEN @row_number + 1
        ELSE 1
    END AS num,
    @customer_no:=customerNumber customerNumber,
    paymentDate,
    amount
FROM
    payments
ORDER BY customerNumber;
Posted by: Guest on June-23-2020

Browse Popular Code Answers by Language