|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
前段时间,得到坛友mn860429、suwenkai的帮助,制作了一个“销售库存总表”,详见http://club.excelhome.net/thread-627622-1-1.html,在公司用了一段时间,效果非常好。非常感谢suwenkai和mn860429!
但这几天公司又新开了一个柜台,于是在原有SQL语句的基础上修改,结果提示“From子句语法错误”,原语句如下(可以用,由坛友suwenkai提供):
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.品名
增加新柜台,并将新柜台命名为“柜台3”,修改后的语句为(该语句提示为“From子句语法错误”,红字为修改的地方):
select a1.类别, a1.品名, sum(入库数量) as 入库数量, sum(出库到柜台1) as 出库到柜台1, sum(出库到柜台2) as 出库到柜台2, sum(出库到柜台3) as 出库到柜台3,sum(出库到其他) as 出库到其他,sum(a2.数量) as 柜台1销售清单,sum(a3.数量) as 柜台2销售清单, sum(a4.数量) as 柜台3销售清单, sum(a5.数量) as 其他销售清单
from
(((select 类别, 品名, sum(入库数量) as 入库数量, sum(出库到柜台1) as 出库到柜台1, sum(出库到柜台2) as 出库到柜台2, sum(出库到柜台3) as 出库到柜台3, sum(出库到其他) as 出库到其他
from [公司出入库$b2:h] 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 [柜台3销售清单$b2:f] group by 品名) a4 on a1.品名=a4.品名) left join
(select 品名,sum(数量) as 数量 from [其他销售清单$b2:f] group by 品名) a5 on a1.品名=a5.品名 group by a1.类别, a1.品名
请各位指教,先谢谢大家!!
还有一个问题要请教大家,在增加柜台3之前,其他都很正常,但有一个问题不得其解:在透视表总表中,橙色文字的几列库存数量,都是通过:数据透视表―→公式―→计算字段,计算而来,但如果按顺序先计算柜台1库存、柜台2库存、公司库存,再计算深圳总库存,柜台1、柜台2和公司库存可以显示出来,而深圳总库存这一列无法显示出来,不知是何原因?是不是透视表总列数有限制?据我观察,好像数据区的总列数十行后就无法显示?是否偶然?请指教!
[ 本帖最后由 brdsz 于 2010-10-6 10:54 编辑 ] |
|