zoukankan      html  css  js  c++  java
  • oracle 查某一列有重复值的记录

    -- 查找重复记录
    select names,num
    from test
    where rowid != (select max(rowid)
                     from test b
                    where b.names = test.names and
                          b.num = test.num)

    或者使用

    select names,num
    from test
    where rownum!= (select max(rownum)
                     from test b
                    where b.names = test.names and
                          b.num = test.num)

     对于sql server 的使用可能没有oracle 那么方便

    如下:

    declare @table table(
      id nchar(20),
      name nchar(10),
      number int
      )
      insert into @table  select id,name, row_number() over(order by id)  number from userapp
      --select *from @table
       select a.id,a.name
    from @table a
    where number!= (select max(number)
                     from @table b
                    where b.id = a.id and
                          b.name = a.name)

    代码是使用表变量进行的处理

  • 相关阅读:
    Qt中使用cout, cin, cerr
    linux下清理系统垃圾
    linux清理内存命令
    boost 特点
    linux boost 安装
    valgrind 的使用及错误信息分析
    ArcGIS Engine 编辑介绍
    ArcGIS Engine 编辑- IWorkspaceEdit
    ArcGIS Engine 编辑- ITask
    CreateFeature与CreateFeatureBuffer区别
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/3725645.html
Copyright © 2011-2022 走看看