查找每个sid的最新一条数据

来源:互联网 发布:100 7 js是什么意思 编辑:程序博客网 时间:2024/05/18 01:04
1.用Max函数
select sid,sdata,stime from hisdata a where stime in (select max(stime) from hisdata where a.sid=sid)

2.用 Not exists

select sid,sdata,stime from hisdata a where not exists(select * from hisdata where a.sid=sid and a.stime<stime)


原创粉丝点击