SQL 如何获取时间最新的记录

-- 方法1
select a.* 
 from table1 a
 where not exists(select 1 
                  from table1 b
                  where b.name=a.name and b.gdtime>a.gdtime)
 
-- 方法2
select a.*
 from table1 a
 inner join
 (select name,
         max(gdtime) 'maxgdtime'
  from table1 
  group by name) b on a.name=b.name and a.gdtime=b.maxgdtime

    原文作者:stephenhendery
    原文地址: https://blog.csdn.net/stephenhendery/article/details/79236671
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞