利用ROW_NUMBER中的partition by 删除重复Key的数据

时间:2023-03-09 09:41:02
利用ROW_NUMBER中的partition by 删除重复Key的数据
With temp As
(
Select ROW_NUMBER() over(partition by LogisticsPlan order by createon) rowID,ID from LogisticsPlan
Where LogisticsPlan IN(
'AGDPM15071704',
'AGDDE15071401',
'SGDPM15071404',
'AGDPM15071404',
'SGDDE15071104'
)
) Delete from LogisticsPlan
where ID IN(
Select ID from temp where rowID>1
)

该情景只用于一个字段数据重复时使用