select
s.class,
s.maths
from
stru s
where
not exists(select 1 from stru where class=s.class and total_price>s.total_price)
s.class,
s.maths
from
stru s
where
not exists(select 1 from stru where class=s.class and total_price>s.total_price)
调试欢乐多
a.class,a.maths
from
stru a,
(select class,max(total_price) as total_price from stru group by class) b
where
a.class=b.class and a.total_price=b.total_price
from stru a
where total_price=(select max(total_price) from stru where class=a.class)
select class,max(maths)
from test a
where total_price=(select max(total_price) from test where class=a.class)
group by class这样当同时有多个total_price为最大时取最大的一个maths.