您好,登錄后才能下訂單哦!
轉自:http://www.maomao365.com/?p=4942
/*建表*/
create table A(keyId int,info varchar(200))
go
/*生成數據*/
insert into A(keyId,info)values
(1,'a'),(2,'b'),(3,'C'),(4,'d'),(5,'e'),
(1,'a'),(21,'b1'),(31,'C1'),(4,'d'),(51,'貓貓小屋'),
(1,'a'),(6,'b1'),(7,'C1'),(4,'d000'),(10,'maomao365.com')
go
/*刪除 keyId重復數據 中的另外幾條*/
delete [A2] from
(select row_number() over (Partition By keyId order by keyId) as keyId2,* from A ) as [A2]
where [A2].keyId2 >1
/*
/*刪除 所有列都重復數據 中的另外幾條*/
delete [A2] from
(select row_number() over (Partition By keyId,info order by keyId) as keyId2,* from A ) as [A2]
where [A2].keyId2 >1
*/
/*展示刪除后的數據*/
select * from A
go
truncate table A
drop table A
go
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。