WITH last_activity AS (
    SELECT *,
           ROW_NUMBER() OVER (PARTITION BY id_user ORDER BY id DESC) AS row_num
    FROM actividades
)
SELECT *
FROM last_activity
WHERE row_num = 1
