这是my table in SQL Fiddle。我想为每个children_id找到1行,其中存在最大in_time。所以预期的输出是:
----+------------+
id | in_time |
----+------------+
16 | 1518909618 |
18 | 1518913186 |
17 | 1518909862 |
----+------------+
这是我的查询,但未提供预期数据:
SELECT a.id, a.in_time
FROM `ca_attendance` AS a
LEFT JOIN (
SELECT MAX(id) AS id, in_time
FROM ca_attendance
GROUP BY children_id
) AS b ON a.id = b.id AND a.in_time = b.in_time
答案 0 :(得分:1)
<AuthenticationTypes>