楼主 亡者天下 |
如下图所示:某大型连锁超市对促销品的分发统计表: 价格表:
计划表:
变更表:
实发表:
现在如何根据这四个表格对促销品进行差异分析呢?
解决方案: 1、先用OLE DB编辑SQL语句对四个表格进行汇总;SQL语句如下:- SELECT "计划" as 状态, 分公司,计划$.促销品,数量 as 计划数量,数量*价格$.价格 as 计划金额,0 as 变更数量,0 as 变更金额,0 as 实发数量,0 as 实发金额 FROM [价格$],[计划$]
- WHERE [计划$].促销品=[价格$].促销品 union all
- SELECT "变更" as 状态, 分公司,变更$.促销品,0 as 计划数量,0 as 计划金额,数量 as 变更数量,数量*价格$.价格 as 变更金额,0 as 实发数量,0 as 实发金额 FROM [价格$],[变更$]
- WHERE [变更$].促销品=[价格$].促销品 union all
- SELECT "实发" as 状态, 分公司,实发$.促销品,0 as 计划数量,0 as 计划金额,0 as 变更数量,0 as 变更金额,数量 as 实发数量,数量*价格$.价格 as 实发金额 FROM [价格$],[实发$]
- WHERE [实发$].促销品=[价格$].促销品
2、对促销品按照前缀使用手动组合进行分类(DJ、JB、JJ、Xj);
3、插入计算字段实发金额- =计划金额+变更金额-实发金额
4、最后进行格式调整得到最终效果如下:
如何对多表促销品进行差异分析.rar
(注:文件放在D盘根目录下) |