sql server 中的 row_number

代码
declare @a table(id int ,name varchar(50))
insert into @a (id,name)
select '1','a'
union all
select '1','a'
union all
select '2','n'
union all
select '2','n'
union all
select '2','n'
union all
select '3','b'
union all
select '3','b';

with b as(
  
SELECT ROW_NUMBER() OVER ( PARTITION BY id,name ORDER BY id) AS rcount,* FROM @a
)
select * from b


原文地址:https://www.cnblogs.com/lfzwenzhu/p/1782113.html