日期:2014-05-18 浏览次数:20486 次
--> 测试数据: [tablefile] if object_id('[tablefile]') is not null drop table [tablefile] create table [tablefile] (fie1 varchar(3),fie2 varchar(2),fie3 varchar(2),ID int) insert into [tablefile] select '001','a','v',1 union all select '001','c','f',2 union all select '002','r','t',3 union all select '003','44','tt',4 union all select '003','5','j',5 union all select '003','5','6',6 ;with maco as ( select row_number() over (partition by fie1 order by (select 1)) as rid,* from [tablefile] ) select fie1,fie2,fie3,ID from maco t where rid>1 /* fie1 fie2 fie3 ID ---- ---- ---- ----------- 001 c f 2 003 5 j 5 003 5 6 6 */
------解决方案--------------------