日期:2014-05-18 浏览次数:20495 次
select * from (select *,row_number()over(partition by sfzh order by xm) as row from table1)t where row=1
------解决方案--------------------
select tid=identity(int,1,1),* into # from A select xm,sfzh,ab,bc from # t where not exists(select 1 from # where sfzh=t.sfzh and tid<t.tid) drop table #
------解决方案--------------------
表中要有唯一ID delete from 表 where 字段1 in (select 字段1 from 表 group by 字段1 having count(字段1)>1) and ID not in(select min(id) from 表 group by 字段1 having count(字段1)>1)