SQL 重复 数据 序号

楼主
SQL 重复 数据 序号
[P]SQL code[/P]
create table #a(a varchar(50),b varchar(10))
insert into #a
select 'aaa','' union all
select 'aaa','' union all
select 'aaa','' union all
select 'aab','' union all
select 'aac','' union all
select 'aac',''


select a,
row_number()over(partition by a order by getdate()) as num
from #a


a    num
aaa    1
aaa    2
aaa    3
aab    1
aac    1
aac    2
[P][/P]

电脑版 Page created in 0.0938 seconds with 4 queries.