表1
 a    b    c
 e1   1    s
 e1   2    t
 e1   3    j
 e2   1    s
 e2   1    s
 e2   2    t
 e2   3    j
 e2   4    k
想得到
a    b    c
e1   3    j
e2   4    k也就是在a相同的情况下,取b的MAX的记录!
谢谢帮忙!

解决方案 »

  1.   

    SELECT BB.* FROM
    (SELECT a, MAX(b) AS B FROM 表1 GROUP BY a) AS AA
    INNER JOIN
    表1 AS BB
    ON AA.a = BB.a AND AA.b = BB.b
      

  2.   

    select t.* from 表1 t where not exists(select 1 from 表1 where a=t.a and b>b.t)
      

  3.   


    select * from 表1 a where not exists(select 1 from 表1 where a=a.a and b>a.b)
      

  4.   

    select * from 表1 a where not exists(select 1 from 表1 where a=a.a and b>a.b)
      

  5.   

    select T.* from 表1 T where b=(select top 1 b from 表1 where a=T.a order by b DESC)