--testcreate table #t(F1 char,F2 int)
insert #t
select 'A',   1
union all select 'A' ,  2
union all select 'B',   3
union all select 'B' ,  4
union all select 'A' ,  5select * from #t select 
case when exists(select 1 from #t where F2 < a.F2 and F1 = a.F1) then '' else F1 end F1,
F2 
from #t a 
order by F2drop table #t

解决方案 »

  1.   


    (所影响的行数为 5 行)F1   F2          
    ---- ----------- 
    A    1
    A    2
    B    3
    B    4
    A    5(所影响的行数为 5 行)F1   F2          
    ---- ----------- 
    A    1
         2
    B    3
         4
         5(所影响的行数为 5 行)
      

  2.   

    --上面的有点错误:
    select 
    case when exists(select 1 from #t where F2 < a.F2 and F1 = a.F1) then '' else F1 end F11,
    F2 
    from #t a 
    order by F1,F2 asc