|
楼主 |
发表于 2010-9-20 12:55
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
回复 8楼 suwenkai 的帖子
suwenkai你好,我今天把把做的表认真的审核了一下,发现透视表中“出库到其他”和“出库到柜台2”的数据不会出现,不知何故?我用的是:
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.品名
没有用你的“union all的做法”,是因为我还要从做的透视表中通过公式计算出“柜台1库存”、“柜台2库存”、“公司库存”,而“union all的做法”无法计算这几个数据
后来又验证了一下坛友mn860429的:
select a.品名,类别,入库数量,出库到柜台1,出库到柜台2,出库到其他,柜台1销售,柜台2销售,其他销售 from
((((select 品名,类别,sum(入库数量) as 入库数量,sum(出库到柜台1) as 出库到柜台1,sum(出库到柜台2) as 出库到柜台2,sum(出库到其他) as 出库到其他 from [公司出入库$b2:g] group by 品名,类别) a left join
(select 品名,sum(数量) as 柜台1销售 from [柜台1销售清单$b2:f] group by 品名) b on a.品名=b.品名) left join
(select 品名,sum(数量) as 柜台2销售 from [柜台2销售清单$b2:f] group by 品名) c on a.品名=c.品名) left join
(select 品名,sum(数量) as 其他销售 from [其他销售清单$b2:f] group by 品名) d on a.品名=d.品名)
也是如此!!!
[ 本帖最后由 brdsz 于 2010-9-20 13:33 编辑 ] |
|