|
我再看了一下,得出来的结果,发现有点问题,看来不能偷懒啊,还是要分组合计数量。。。
select a1.类别, a1.品名, sum(入库数量) as 入库数量, sum(出库到柜台1) as 出库到柜台1, sum(出库到柜台2) as 出库到柜台2, sum(出库到其他) as 出库到其他,sum(a2.数量) as 柜台1销售清单,sum(a3.数量) as 柜台2销售清单,sum(a4.数量) as 其他销售清单
from
(((select 类别, 品名, sum(入库数量) as 入库数量, sum(出库到柜台1) as 出库到柜台1, sum(出库到柜台2) as 出库到柜台2, sum(出库到其他) as 出库到其他
from [公司出入库$b2:g] group by 类别, 品名)a1 left join
(select 品名,sum(数量) as 数量 from [柜台1销售清单$b2:f] group by 品名) a2 on a1.品名=a2.品名) left join
(select 品名,sum(数量) as 数量 from [柜台2销售清单$b2:f] group by 品名) a3 on a1.品名=a3.品名) left join
(select 品名,sum(数量) as 数量 from [其他销售清单$b2:f] group by 品名) a4 on a1.品名=a4.品名 group by a1.类别, a1.品名
[ 本帖最后由 suwenkai 于 2010-9-18 17:01 编辑 ] |
|