update prem_info_tax pi
set status = 'N'
where status = 'Y'
and exists (select 1
from (select pk_serial, max(created_date) mcd
from prem_info_tax
where created_date > date '2016-05-01'
and status = 'Y' having count(1) > 1
group by pk_serial) a
where a.pk_serial = pi.pk_serial
and a.mcd <> pi.created_date);
保留最后的一条数据为Y
最新推荐文章于 2024-07-15 18:07:55 发布