(select 产品,班组,sum(产量) from p gorup by 产品,班组)
union
(select 产品='合计',班组='',sum(产量) form p)
order by 3

解决方案 »

  1.   

    select * from ( 
    (select 产品,班组,sum(产量) from p gorup by 产品,班组)
    union
    (select 产品='合计',班组='',sum(产量) form p) ) aaorder by (case aa.产品 when '合计' then 1 else 0 end) 
      

  2.   

    最前:
    (select 产品,班组,sum(产量) from p gorup by 产品,班组)
    union
    (select 产品='合计',班组='',sum(产量) form p)
    order by 3 desc
      

  3.   

    (select 产品,班组,sum(产量) from p gorup by 产品,班组)
    union all
    (select 产品='合计',班组='',sum(产量) form p)
      

  4.   

    select 产品,班组,sum(产量) from p gorup by 产品,班组
    union
    select 产品='合计',班组='',sum(产量) form p
    order by case 产品 when '合计' then 1 else 0 end
      

  5.   

    select 产品,班组,sum(产量) from test group by 产品,班组 
    union all
    select 产品='合计',班组='',sum(产量) from p order by 产品