先查询到不同组的最大值,然后求最大值的和
谢谢!!

解决方案 »

  1.   

    select sum(a.max_in_qty) as sum_in_qty from
      ( select stk_type,code_no,max(in_qty) as max_in_qty 
          from indepotc
           group by stk_type,code_no) a
      

  2.   

    不是很明白楼主的意思,什么是不同组的最大值?既然可以累加,那就应该是加一列
    既然是同一列,那又为什么要Max呢?加个条件不就可以了吗?建议楼主把问题说清楚一点
      

  3.   

    B        C      
    1 12.5
    1 2.8
    1 4
    1 6.08
    1 1.2
    1 1.2
    2 0.5
    1 2.08
    2 4.3
    2 8.1
    2 8.1
    2 3.8
    1 1.2
    将B相同的分为一组,取一组中C最大的值,然后将最大的几个C相加。
    谢谢各位啊!!
      

  4.   

    select sum(a.max_in_qty) as sum_in_qty from
      ( select b,max(c) as max_in_qty 
          from 表名
           group by b) a
      

  5.   

    select sum(a.max_c) as sum_c from
      ( select b,max(c) as max_c
          from 表名
           group by b) a