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)

解决方案 »

  1.   

    select
        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
      

  2.   

    select class,maths
    from stru a
    where total_price=(select max(total_price) from stru where class=a.class)
      

  3.   

    修改下冒牌的:
    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.