Skip to main content
1 de 2
Leandro Amorim
  • 1,9mil
  • 10
  • 19

No MySQL 8.0 existe a possibilidade de usar RANK()

SELECT
    id, usuario_id, status
FROM (
  SELECT 
    id, usuario_id, status,
    RANK() OVER (PARTITION BY usuario_id ORDER BY id DESC) AS intRow
  FROM
    Table1
  WHERE
    status = 0
) T
WHERE
    intRow = 1

https://www.db-fiddle.com/f/7V6HBDsCmd4m9uPiz9cnWY/0

Leandro Amorim
  • 1,9mil
  • 10
  • 19