删除重复数据,保留一行
-- 删除某几列相同的,重复数据
delete from Process.SSC_HqItemConfig
WHERE
ID NOT IN
(
select min(ID) from Process.SSC_HqItemConfig group by CompanyCode, FlowCode, ActivityType, BusinessCode
having count(CompanyCode)>1
)
AND
exists
(
-- 匹配原来某些列
delete from Process.SSC_HqItemConfig
WHERE
ID NOT IN
(
select min(ID) from Process.SSC_HqItemConfig group by CompanyCode, FlowCode, ActivityType, BusinessCode
having count(CompanyCode)>1
)
AND
exists
(
-- 匹配原来某些列
select * from (
SELECT CompanyCode, FlowCode, ActivityType, BusinessCode
FROM Process.SSC_HqItemConfig b
GROUPby CompanyCode, FlowCode, ActivityType, BusinessCode
having count(CompanyCode) >1
) b
WHERE b.CompanyCode = CompanyCode AND b.FlowCode = FlowCode
AND b.ActivityType = ActivityType AND b.ActivityType = ActivityType
)
走向地狱的途中,不小心走了程序员这条路,路上一个个黑心的老板,和暗无天日的加班,我才发现,通往地狱的路径中,我们这行是最短的。