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
select a,b,c,d from t a where not exists(select 1 from t where b=a.b and c>a.c)
搞错: 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)
测试: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)
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
select a,b,c,d
from t a
where not exists(select 1 from t where b=a.b and c>a.c)
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)
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)