里筛选出每一人的时间最新的一条记录

白诗秀儿 关注

收藏于 : 2017-09-22 17:21   被转藏 : 1   

-- 方法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
 阅读文章全部内容  
点击查看
文章点评
相关文章
白诗秀儿 关注

文章收藏:1308

TA的最新收藏