方法很多
1.按你的写法 这么改
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
你group by sid
就是按sid分组取每组里面stime最大的sid
如果只想一条数据
就不加group by
select max(stime) from hisdata group by sid )
你加个distinct 试试
select sid,sdata,stime from hisdata where stime in (select max(stime) from hisdata)
stime 不是唯一