Goupy by 子句中的內容有以下限制:
  不能使用列標題
  不能包含統計函數
  不能包含Text,image或bit數據類型的列或變量三少

解决方案 »

  1.   

    select 仓库,
           卡片号,
           sum(入库金额+出库金额) as 总金额,
           sum(入库金额) as 入库金额,
           sum(出库金额) as 出库金额
        from (
            select 仓库,卡片号,sum(金额) as 入库金额, 0 as 出库金额 from A where 进出标志='+' group by 仓库,卡片号
            union
            select 仓库,卡片号,0 as 入库金额, sum(金额) as 出库金额 from A where 进出标志='-'  group by 仓库,卡片号
             ) BB    group by 仓库,卡片号
       
      

  2.   

    select 仓库,
          卡片号,
         进出标志,
          sum(金额) as 入库金额,
          sum(金额) as 出库金额,
          入库金额+出库金额
          group by rollup(仓库,卡片号,进出标志)