oracle分组后的整条记录怎么取

2024-12-15 22:58:10
推荐回答(2个)
回答1:

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

回答2:

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