我的数据库有问题
Select * from table where JobId='329188628'
结果:
ID JobId ONETID
-----------------------
32951 329188628 532
32951 329188628 532
32951 329188628 532
32951 329188628 532
我需要删除重复的行。谁能帮帮我吗 ?
我的数据库有问题
Select * from table where JobId='329188628'
结果:
ID JobId ONETID
-----------------------
32951 329188628 532
32951 329188628 532
32951 329188628 532
32951 329188628 532
我需要删除重复的行。谁能帮帮我吗 ?
尝试这个。
with cte(cnt) as
(
select row_number() over(partition by ID,JobId,ONETID order by getdate())
from table where JobId='329188628'
)
delete from cte where cnt>1
并且只有 JobId 和 OnetId 用于分组。
with cte(cnt) as
(
select row_number() over(partition by JobId,ONETID order by getdate())
from table where JobId='329188628'
)
delete from cte where cnt>1
请试试:
with c as(
select *, row_number() over(partition by id order by (select 0)) as n
from table where JobID='329188628'
)delete from c
where n > 1;
使用DISTINCT
关键字。
Select DISTINCT * from table where JobId='329188628'