ls_h    sl        hp_h
1       100       001
1       200       001
1       300       001
2       150       001
2       700       001求出hp_h是001 的最大值的和就是  300+700=1000

解决方案 »

  1.   

    select sum(sl) sl
    from (
      select max(sl) sl
      from tb
      group by ls_h
    ) as t
      

  2.   

    select sum(sl) sl
    from (
      select max(sl) sl
      from tb
      group by ls_h
      where hp_h='001'
    ) as tMODIFY
      

  3.   

    select sum(sl) sl
    from (
      select max(sl) sl
      from tb
      where hp_h='001'
      group by ls_h
    ) as t不好意思,手误,以此为准
      

  4.   

    select sum(sl) as s from (select max(sl) as sl ,ls_h from tb group by ls_h) as ts