sql server 去掉重复项

select *FROM ( SELECT Row_Number() OVER ( PARTITION BY [OrderNum] ORDER BY ( SELECT 0
) ) AS RowNO , *FROM [GomeCPS].[dbo].[a17]) t WHERE T.RowNO > 1 ;

select * From [GomeCPS].[dbo].[a17] Where [OrderNum] in (
select [OrderNum]
From [GomeCPS].[dbo].[a17] Group By [OrderNum] Having Count([OrderNum])>1);

Delete T From(
Select Row_Number() Over(Partition By [OrderNum] Order By (SELECT 0)) As RowNumber,*
From [GomeCPS].[dbo].[a17]) T
Where T.RowNumber > 1;

 

Delete From Employee Where Name in (
select Name
From Employee Group By Name Having Count(Name)>1);

posted @ 2016-01-18 16:27  昙花千尺  阅读(290)  评论(0编辑  收藏  举报