分组查最新记录

----------------------------分组查最新条记录
select a.cur_id,a.old_exchange_rate,a.new_exchange_rate from fc_excrate_adjust a
inner join (select cur_Id,max(pre_time)as preTime from fc_excrate_adjust fe where fe.pre_time<=to_date('2020-05-11', 'yyyy-MM-dd')
group by cur_Id)bs on bs.cur_Id=a.cur_id and bs.preTime = a.pre_time;

原文地址:https://www.cnblogs.com/ketoli/p/14171431.html