告诉你个高级点的方法,用开窗函数
select * from
(
select id,fid,time,name,rank()over(partition by fid order by time desc) mm from a
)
where mm=1
select a.* from a,(select fid,max(time) time from a group by fid) b
where a.fid=b.fid and a.time=b.time