ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

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

[求助] Access 中如何实现行数据之间的计算

[复制链接]

TA的精华主题

TA的得分主题

发表于 2009-9-4 13:17 | 显示全部楼层 |阅读模式
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
最近做一个东东,涉及到行之间关系计算,这在excel中比较容易实现,但是数据量太大。 要实现的结果如附件所示。
前四行不需要动,后两行是我想添加的,里面有公式。呵呵,帮帮忙看如何实现。

Book1.rar

2.72 KB, 下载次数: 91

TA的精华主题

TA的得分主题

发表于 2009-9-4 13:44 | 显示全部楼层
没明白楼主的意思
是要在access中添加类是附件中的两行数据吗?

TA的精华主题

TA的得分主题

 楼主| 发表于 2009-9-4 13:49 | 显示全部楼层
恩,要添加最后的两行,这两行的数据是按照公式算出来的。

TA的精华主题

TA的得分主题

发表于 2009-9-6 08:03 | 显示全部楼层
呵呵,你的公式有乱码呢,我将你的公式往后拖
红色部分数据源放到Sheet2表中,来一个长的SQL语句如下:
select * from [sheet2]
union all
select "PXadj",5,0 as c1,iif(a5<>a6,b5,c1) as c2,iif(a6<>a7,b6,c2) as c3,iif(a7<>a8,b7,c3) as c4,iif(a8<>a9,b8,c4) as c5,iif(a9<>a10,b9,c5) as c6,iif(a10<>a11,b10,c6) as c7,iif(a11<>a12,b11,c7),null from
(
select sum(M5_2008) as a5,sum(M6_2008) as a6,sum(M7_2008) as a7,sum(M8_2008) as a8,sum(M9_2008) as a9,sum(M10_2008) as a10,sum(M11_2008) as a11,sum(M12_2008) as a12,sum(M5) as b5,sum(M6) as b6,sum(M7) as b7,sum(M8) as b8,sum(M9) as b9,sum(M10) as b10,sum(M11) as b11 from
(
select M5_2008,M6_2008, M7_2008, M8_2008, M9_2008, M10_2008, M11_2008, M12_2008,0 as M5,0 as M6,0 as M7,0 as M8,0 as M9,0 as M10,0 as M11 from [Sheet2$] where row="GBD" union all select 0,0,0,0,0,0,0,0,M5_2008,M6_2008, M7_2008, M8_2008, M9_2008, M10_2008, M11_2008 from [Sheet2$] where row="PX"
)
)
union all
select "policy year",6,0 as d1,iif(c1<>c2,d1+1,d1) as d2,iif(c2<>c3,d2+1,d2) as d3,iif(c3<>c4,d3+1,d3) as d4,iif(c4<>c5,d4+1,d4) as d5,iif(c5<>c6,d5+1,d5) as d6,iif(c6<>c7,d6+1,d6) as d7,iif(c7<>c8,d7+1,d7),null
from
(
select "PXadj",5,0 as c1,iif(a5<>a6,b5,c1) as c2,iif(a6<>a7,b6,c2) as c3,iif(a7<>a8,b7,c3) as c4,iif(a8<>a9,b8,c4) as c5,iif(a9<>a10,b9,c5) as c6,iif(a10<>a11,b10,c6) as c7,iif(a11<>a12,b11,c7) as c8 from
(
select sum(M5_2008) as a5,sum(M6_2008) as a6,sum(M7_2008) as a7,sum(M8_2008) as a8,sum(M9_2008) as a9,sum(M10_2008) as a10,sum(M11_2008) as a11,sum(M12_2008) as a12,sum(M5) as b5,sum(M6) as b6,sum(M7) as b7,sum(M8) as b8,sum(M9) as b9,sum(M10) as b10,sum(M11) as b11 from
(
select M5_2008,M6_2008, M7_2008, M8_2008, M9_2008, M10_2008, M11_2008, M12_2008,0 as M5,0 as M6,0 as M7,0 as M8,0 as M9,0 as M10,0 as M11 from [Sheet2$] where row="GBD" union all select 0,0,0,0,0,0,0,0,M5_2008,M6_2008, M7_2008, M8_2008, M9_2008, M10_2008, M11_2008 from [Sheet2$] where row="PX"
)
)
)

calculate.rar

5.93 KB, 下载次数: 98

TA的精华主题

TA的得分主题

 楼主| 发表于 2009-9-8 10:40 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
非常感谢Scarlett_88版主!!!,

版主的解法是基于a5=sum(M5_2008)...来判断的,对于有多个相同格式的数据,我还是不能处理。可能我最初的表述并没有反映我最终想要的结果,我重新整理了一下我的示例。希望能再次等到版主的支持!
"Org"sheet 是最初的表,“cal”sheet是中间计算PY和PXAdj的表,“final”sheet是我最终想要的表
再次感谢!!!

[ 本帖最后由 chench 于 2009-9-8 17:24 编辑 ]

calculate.rar

12.71 KB, 下载次数: 74

TA的精华主题

TA的得分主题

发表于 2009-9-13 12:36 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
非常感谢版主..........

TA的精华主题

TA的得分主题

发表于 2009-9-14 17:03 | 显示全部楼层

TA的精华主题

TA的得分主题

 楼主| 发表于 2009-9-16 13:02 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册

回复 4楼 Scarlett_88 的帖子

版主何时再出现啊????
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

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

GMT+8, 2025-1-13 10:50 , Processed in 0.022587 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

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

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

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