SLECT a, b, c, d FROM [table] a WHERE b IN (SELECT TOP 1 b FROM [table] WHERE a = a.a order by c DESC)

解决方案 »

  1.   

    select t.*
    from (select b,max(c) as c from table group by b) x
    inner join table t on x.b=t.b and x.c=t.c
      

  2.   


    select a,b,c,d 
    from t a 
    where not exists(select 1 from t where b=a.b and c>a.c)
      

  3.   

    搞错:
    SELECT a, b, c, d FROM Test10 a WHERE a IN (SELECT TOP 1 a FROM Test10 WHERE b = a.b order by c DESC)
      

  4.   

    测试:declare @Test table (a int, b int, c int, d int)
    insert @Test
    select 1, 1, 1, 1
    union all select 2, 1, 2, 9
    union all select 3, 1, 3, 5
    union all select 4, 2, 2, 4
    union all select 5, 3, 1, 1select * from @TestSELECT a, b, c, d FROM @Test a WHERE a IN (SELECT TOP 1 a FROM @Test WHERE b = a.b order by c DESC)
      

  5.   

    我采用了lsxaa(小李铅笔刀) 的