select 商品编号
,买出数量=sum(case 状态A when 0 then 数量 else 0 end)
,库存数量=sum(case 状态A when 1 then 数量 else 0 end)
,已经得到回款的数量=sum(case 状态B when 1 then 数量 else 0 end)
,没有得到回款的数量=sum(case 状态B when 0 then 数量 else 0 end)
,操作员
from 表
group by 商品编号,操作员
,买出数量=sum(case 状态A when 0 then 数量 else 0 end)
,库存数量=sum(case 状态A when 1 then 数量 else 0 end)
,已经得到回款的数量=sum(case 状态B when 1 then 数量 else 0 end)
,没有得到回款的数量=sum(case 状态B when 0 then 数量 else 0 end)
,操作员
from 表
group by 商品编号,操作员
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货