现在有个表:
                字段A, 字段B
                  T1     a
                  T2     a
                  T3     a
                  T4     b
                  T5     b
                  T6     b
                  T7     c
                  T8     c
                  T9     c
       希望查询的结果为:
                  T1     a
                  T4     b
                  T7     c
谢谢!

解决方案 »

  1.   


    select 字段A, 字段B
    from 表
    where 字段A in(select min(字段A) from 表 group by 字段B)
      

  2.   

    select * from t t1 where A = (select min(A) from t t2 where t1.B= t2.B)
      

  3.   

    select * from t t1 where not exists(select 1 from t t2 where t1.B = t2.B and t1.A > t2.A)
      

  4.   


    select min(a) a,b
    from tb
    group by b
      

  5.   

    select 字段A, 字段B
    from 表 t 
    where not exists(select 1 from 表 where 字段B = t.字段B and 字段A > t.字段A)
      

  6.   

    select
     字段A, 字段B
    from
     表 t
    where
     字段A =(select min(字段A) from 表 字段B=t.字段B)
      

  7.   

    select distinct (select top 1 字段A from 表 where 字段B=a.字段B) as 字段A,字段B from 表 a