`
xsl2007
  • 浏览: 133893 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

查询出重复数据

 
阅读更多
select *
  from hlinsuredinfo a
 where (GrpContNo, insuredname, doctype, docNo) in
       (select GrpContNo, insuredname, doctype, docNo
          from (select GrpContNo, insuredname, doctype, docNo, count(*) co
                  from hlinsuredinfo
                 group by GrpContNo, insuredname, doctype, docNo)
         where co > 1)
   and rowid not in (select min(rowid)
                       from hlinsuredinfo
                      group by GrpContNo, insuredname, doctype, docNo
                     having count(*) > 1)

上述sql语句用于查询重复数据,若需要删除,将select * from 改为delete from 即可
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics