删除重复数据,保留一条ID最小的

SELECT * from TBCITY_Temp
where code 
 in (
  select
   code
    from TBCITY_Temp
   group by code
  having count(code) > 1
  )
and   AutoId not in (
      select min(AutoId)
        from TBCITY_Temp
       group by code    
      having count(code)>1)

-- 条件为code再重复数据里,and Id 不是最小的

posted @ 2015-04-22 11:28  chengeng  阅读(190)  评论(0编辑  收藏  举报