select identity(int,1,1) as id,* into #T from 表Aselect 
    a.* 
from 
    #T a 
where 
    not exists(select 1 from #T where vol1=a.vol1 and id<a.id)

解决方案 »

  1.   

    declare @t table(vol1 int,vol2 int,vol3 int)
    insert into @t select 1,1,1
    insert into @t select 1,0,1
    insert into @t select 2,1,0
    insert into @t select 3,3,1
    insert into @t select 2,3,4
    select 
        a.* 
    from 
        @t a 
    where 
        not exists(select 1 from @t where vol1=a.vol1 and vol2>a.vol2)?8
    vol1        vol2        vol3        
    ----------- ----------- ----------- 
    1           1           1
    3           3           1
    2           3           4*/
      

  2.   

    哦 这个无所谓 要那个都行只要是提取出来 vol1 不同的旧可以但是你的方法 似乎有时候不行
    比如
    2 0 3
    2 0 4如果用你的方法的话 这2个会都出现