日期:2014-05-18 浏览次数:20445 次
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 * from #a 我要得到数据 aaa 01 aaa 02 aaa 03 aab 01 aac 01 aac 02
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
------解决方案--------------------