请教一个排序问题,希望高手来看看
有表   table1 
 结构如下:   
    a               b             
    11            1                
    11            1 
    11            1 
    22            1 
    22            1 
    22            1 
    22            1 
    33            1 
    33            1   
 怎样能获得如下结果 
       a               b 
       11            1 
       11            2 
       11            3 
       22            1 
       22            2 
       22            3    
       22            4 
       33            1 
       33            2   
 谢谢! 
------解决方案--------------------  create table table1( a int,    b int) 
 insert table1 select 11,    1      
 union all select 11,    1 
 union all select 11,    1 
 union all select 22,    1 
 union all select 22,    1 
 union all select 22,    1 
 union all select 22,    1 
 union all select 33,    1 
 union all select 33,    1     
 select id=identity(int,1,1), a,b into # from table1  
 select a,(select count(*) from # b where b.id <=a.id and b.a=a.a) from # a 
 drop table #