您的位置:首页 > 数据库

数据库的一个表里筛选出每一人的时间最新的一条记录

2016-11-10 12:18 543 查看
-- 方法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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐