-- 查找重复记录
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)

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

相关文章:

  • 2021-05-31
  • 2021-11-02
  • 2022-12-23
  • 2021-06-20
  • 2021-12-23
  • 2021-07-18
猜你喜欢
  • 2022-02-10
  • 2021-12-30
  • 2022-12-23
  • 2022-02-16
  • 2022-12-23
  • 2022-03-06
相关资源
相似解决方案