使用sql查询每个人的最新的一条数据

select a1.* from demo1 as a1
inner join
(
    select a2.code,max(a2.create_time) as newDate
    from demo1 as a2
    group by a2.code
)
as a3 on a1.code = a3.code and a1.create_time = a3.newDate

思路:懒得写

你可能感兴趣的:(使用sql查询每个人的最新的一条数据)