您好,登錄后才能下訂單哦!
轉(zhuǎn)自:http://www.maomao365.com/?p=4942
/*建表*/
create table A(keyId int,info varchar(200))
go
/*生成數(shù)據(jù)*/
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重復(fù)數(shù)據(jù) 中的另外幾條*/
delete [A2] from
(select row_number() over (Partition By keyId order by keyId) as keyId2,* from A ) as [A2]
where [A2].keyId2 >1
/*
/*刪除 所有列都重復(fù)數(shù)據(jù) 中的另外幾條*/
delete [A2] from
(select row_number() over (Partition By keyId,info order by keyId) as keyId2,* from A ) as [A2]
where [A2].keyId2 >1
*/
/*展示刪除后的數(shù)據(jù)*/
select * from A
go
truncate table A
drop table A
go
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。