答案 0 :(得分:1)
使用ansi-sql,您只需要具有group by和聚合功能的子选择:
SELECT distinct last_record.*
FROM changesets AS c
INNER JOIN
(SELECT c2.user,
MAX(c2.created_at) AS max_timestamp
FROM changesets AS c2
GROUP BY c2.user) AS last_record
ON c.user = last_record.user
当然不要忘记,如果deviceId不是主键或非唯一键,这将从 last_record 返回多行,因此您需要与众不同 < / p>