update a set DelFlag=1 from Mall_ShopAcitivityGoods a
inner join (
select SAG_GbpvID gbpvid,max(sag_id) id from Mall_ShopAcitivityGoods where SAG_ActivityID='20f2664e-4575-462a-93dd-f7b9eb5afade' and DelFlag=0 group by SAG_GbpvID
) b
on SAG_GbpvID=gbpvid and SAG_ID<>id where SAG_ActivityID='20f2664e-4575-462a-93dd-f7b9eb5afade' and DelFlag=0