ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 效率神器,一键搞定繁琐工作
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
让更多数据处理,一键完成 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 4186|回复: 7

直接按周 透视 数据

[复制链接]

TA的精华主题

TA的得分主题

发表于 2010-4-29 09:51 | 显示全部楼层 |阅读模式
这个是我已写好的,用excel透视acess里面的数据,因为数据量很大,有325M且以后还要增加,所以我想直接按周来透视汇总数据,这样提高透视的速度。(不是透视完数据,然后按周计算。)
  1. select 经销商名称,款号,综合类别,商品颜色,性别,商务大类,商务小类,日期,年份,实际发货数量,0 as 实际销售数量,0 as 实际零售数量,实际发货金额,0 as 实际销售金额,0 as 实际零售金额,预计发货成本额,0 as 预计销售成本额,0 as 零售成本额,预计发货毛利,0 as 预计销售毛利,0 as 预计零售毛利,供应商名称,采购单价,材质,0 as 订单数量,跟型,筒高 from [发货查询] union all

  2. select 经销商名称,款号,综合类别,商品颜色,性别,商务大类,商务小类,日期,年份,0 as 实际发货数量,实际销售数量,0 as 实际零售数量,0 as 实际发货金额,实际销售金额,0 as 实际零售金额,0 as 预计发货成本额,预计销售成本额,0 as 预计零售成本额,0 as 预计发货毛利,预计销售毛利,0 as 预计零售毛利,供应商名称,采购单价,材质,0 as 订单数量,跟型,筒高 from [销售查询] union all

  3. select 经销商名称,款号,综合类别,商品颜色,性别,商务大类,商务小类,日期,年份,0 as 实际发货数量,0 as 实际销售数量,实际零售数量,0 as 实际发货金额,0 as 实际销售金额,实际零售金额,0 as 预计发货成本额,0 as 预计销售成本额,预计零售成本额,0 as 预计发货毛利,0 as 预计销售毛利,预计零售毛利,供应商名称,采购单价,材质,0 as 订单数量,跟型,筒高 from [零售查询] UNION ALL

  4. select 经销商名称,款号,综合类别,商品颜色,性别,商务大类,商务小类,日期,年份,0 as 实际发货数量,0 as 实际销售数量,0 as 实际零售数量,0 as 实际发货金额,0 as 实际销售金额,0 as 实际零售金额,0 as 预计发货成本额,0 as 预计销售成本额,0 as 预计零售成本额,0 as 预计发货毛利,0 as 预计销售毛利,0 as 预计零售毛利,供应商名称,采购单价,材质,订单数量,跟型,筒高 from [订单查询];
复制代码
是否可以这样:
  1. select 经销商名称,款号,综合类别,商品颜色,性别,商务大类,商务小类,year(日期) &"年第" & datediff('ww',year(日期)&'-1-1',日期)+1 & "周" as 按周,年份,实际发货数量,0 as 实际销售数量,0 as 实际零售数量,实际发货金额,0 as 实际销售金额,0 as 实际零售金额,预计发货成本额,0 as 预计销售成本额,0 as 零售成本额,预计发货毛利,0 as 预计销售毛利,0 as 预计零售毛利,供应商名称,采购单价,材质,0 as 订单数量,跟型,筒高 from [发货查询] union all

  2. select 经销商名称,款号,综合类别,商品颜色,性别,商务大类,商务小类,year(日期) &"年第" & datediff('ww',year(日期)&'-1-1',日期)+1 & "周" as 按周,年份,0 as 实际发货数量,实际销售数量,0 as 实际零售数量,0 as 实际发货金额,实际销售金额,0 as 实际零售金额,0 as 预计发货成本额,预计销售成本额,0 as 预计零售成本额,0 as 预计发货毛利,预计销售毛利,0 as 预计零售毛利,供应商名称,采购单价,材质,0 as 订单数量,跟型,筒高 from [销售查询] union all

  3. select 经销商名称,款号,综合类别,商品颜色,性别,商务大类,商务小类,year(日期) &"年第" & datediff('ww',year(日期)&'-1-1',日期)+1 & "周" as 按周,年份,0 as 实际发货数量,0 as 实际销售数量,实际零售数量,0 as 实际发货金额,0 as 实际销售金额,实际零售金额,0 as 预计发货成本额,0 as 预计销售成本额,预计零售成本额,0 as 预计发货毛利,0 as 预计销售毛利,预计零售毛利,供应商名称,采购单价,材质,0 as 订单数量,跟型,筒高 from [零售查询] UNION ALL

  4. select 经销商名称,款号,综合类别,商品颜色,性别,商务大类,商务小类,year(日期) &"年第" & datediff('ww',year(日期)&'-1-1',日期)+1 & "周" as 按周,年份,0 as 实际发货数量,0 as 实际销售数量,0 as 实际零售数量,0 as 实际发货金额,0 as 实际销售金额,0 as 实际零售金额,0 as 预计发货成本额,0 as 预计销售成本额,0 as 预计零售成本额,0 as 预计发货毛利,0 as 预计销售毛利,0 as 预计零售毛利,供应商名称,采购单价,材质,订单数量,跟型,筒高 from [订单查询];
复制代码

TA的精华主题

TA的得分主题

 楼主| 发表于 2010-4-29 09:52 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
我感觉第二种方法本质上也是按日期来透视的,请问高手,有没有更好或者更快速有效的方法?

[ 本帖最后由 kumoo 于 2010-4-29 09:53 编辑 ]

TA的精华主题

TA的得分主题

发表于 2010-4-29 09:57 | 显示全部楼层
不是可以用分组功能按周显示么?为什么要这样写?

TA的精华主题

TA的得分主题

 楼主| 发表于 2010-4-29 10:18 | 显示全部楼层

TA的精华主题

TA的得分主题

 楼主| 发表于 2010-4-29 11:30 | 显示全部楼层
select 经销商名称,款号,综合类别,商品颜色,性别,商务大类,商务小类,DatePart("ww",[日期]) AS 週,年份,0 as 实际发货数量,0 as 实际销售数量,0 as 实际零售数量,0 as 实际发货金额,0 as 实际销售金额,0 as 实际零售金额,0 as 预计发货成本额,0 as 预计销售成本额,0 as 预计零售成本额,0 as 预计发货毛利,0 as 预计销售毛利,0 as 预计零售毛利,供应商名称,采购单价,材质,订单数量,跟型,筒高 from [订单查询] GROUP BY DatePart("ww",[日期]) where (按经销商名称和款号汇总)

TA的精华主题

TA的得分主题

 楼主| 发表于 2010-4-29 11:44 | 显示全部楼层
直接在ACESS查询里,修改日期为:(周: Year([日期]) & "年第" & DateDiff('ww',Year([日期]) & '-1-1',[日期])+1 & "周")

我想会有改善

TA的精华主题

TA的得分主题

发表于 2010-4-29 12:26 | 显示全部楼层
你不发附件,别人很难参与

TA的精华主题

TA的得分主题

 楼主| 发表于 2010-4-29 13:18 | 显示全部楼层
SELECT 总部发货表.经销商名称, 总部发货表.款号, Year([日期]) & "年第" & DateDiff('ww',Year([日期]) & '-1-1',[日期])+1 & "周" AS 周, Sum(总部发货表.实际发货数量) AS 实际发货数量之总计, Sum(总部发货表.实际发货金额) AS 实际发货金额之总计, Sum(总部发货表.预计发货成本额) AS 预计发货成本额之总计, Sum(总部发货表.预计发货毛利) AS 预计发货毛利之总计, 款号信息档案查询.年份, 款号信息档案查询.性别, 款号信息档案查询.综合类别, 款号信息档案查询.商务大类, 款号信息档案查询.商务小类, 款号信息档案查询.商品颜色, 款号信息档案查询.采购单价, 款号信息档案查询.材质, 款号信息档案查询.供应商名称, 款号信息档案查询.供应商编号, 款号信息档案查询.跟型, 款号信息档案查询.筒高
FROM 款号信息档案查询 RIGHT JOIN 总部发货表 ON 款号信息档案查询.款号 = 总部发货表.款号
GROUP BY 总部发货表.经销商名称, 总部发货表.款号, Year([日期]) & "年第" & DateDiff('ww',Year([日期]) & '-1-1',[日期])+1 & "周", 款号信息档案查询.年份, 款号信息档案查询.性别, 款号信息档案查询.综合类别, 款号信息档案查询.商务大类, 款号信息档案查询.商务小类, 款号信息档案查询.商品颜色, 款号信息档案查询.采购单价, 款号信息档案查询.材质, 款号信息档案查询.供应商名称, 款号信息档案查询.供应商编号, 款号信息档案查询.跟型, 款号信息档案查询.筒高;
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-11-28 22:41 , Processed in 0.057492 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表