- SQL code
create table #a(a varchar(50),b varchar(10))insert into #aselect 'aaa','' union allselect 'aaa','' union allselect 'aaa','' union allselect 'aab','' union allselect 'aac','' union allselect 'aac','' select * from #a我要得到数据aaa 01aaa 02aaa 03aab 01aac 01aac 02
------解决方案--------------------
- SQL code
create table #a(a varchar(50),b varchar(10))insert into #aselect 'aaa','' union allselect 'aaa','' union allselect 'aaa','' union allselect 'aab','' union allselect 'aac','' union allselect 'aac','' select a,row_number()over(partition by a order by getdate()) as numfrom #aa numaaa 1aaa 2aaa 3aab 1aac 1aac 2
------解决方案--------------------