Ejemplo 1: ejemplo de mysql row_number ()
SET @row_number = 0;
SELECT
(@row_number:=@row_number + 1) AS num,
firstName,
lastName
FROM
employees
ORDER BY firstName, lastName
LIMIT 5;
Ejemplo 2: obtener el número de fila en 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;
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)