sqlserver 清掉工件号重复的数据
单主键
with T as( SELECT ROW_NUMBER() over (PARTITION By 工件号 order by 检测时间 desc) as rowid,* FROM 检测表 ) delete from T where id not in( select id from T where rowid = 1)
组合主键
with T as( SELECT ROW_NUMBER() over (PARTITION By MachineCode,Content,CreationTime order by id ) as rowid,* FROM [OperationRecords2021-03-01] ) delete from T where id not in( select id from T where rowid = 1)
Newd
版权声明
作者:も不秃不秃
地址:https://www.cnblogs.com/Newd/p/13878713.html
© Newd 尊重知识产权,引用请注出处
广告位
(虚位以待,如有需要请私信)