在同一张表存在多条记录,只修改最近的一条

时间:2021-05-26 14:43:50
UPDATE RT_INSURANCEBUY T SET INSURERCODE = '03' WHERE T.FRAMENO = 'LHGCM462242025161' AND T.BUYDATE = ( 
SELECT T2.BUYDATE FROM RT_INSURANCEBUY T1
LEFT JOIN (SELECT MAX(BUYDATE) AS BUYDATE ,FRAMENO FROM RT_INSURANCEBUY GROUP BY FRAMENO) T2 ON T1.FRAMENO = T2.FRAMENO AND T1.BUYDATE = T2.BUYDATE
WHERE T2.FRAMENO = 'LHGCM462242025161')