ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

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

联合查询的SQL语句写出来总说有错,帮一下忙哈!

[复制链接]

TA的精华主题

TA的得分主题

发表于 2005-4-21 14:49 | 显示全部楼层
不用那么复杂,联合查询关键是每个查询列要相同.

TA的精华主题

TA的得分主题

 楼主| 发表于 2005-4-21 15:18 | 显示全部楼层

??????

没明白,具体怎么做呀?我现在是刚刚知道点儿,只要你说明白我就开窍啦!

TA的精华主题

TA的得分主题

发表于 2005-4-21 15:35 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
我只会照着改改,还请版主明示

TA的精华主题

TA的得分主题

发表于 2005-4-21 22:31 | 显示全部楼层

select Year,Subscriber,Value from sheet1 union all

SELECT sheet1.Year & " 小计" AS 表达式1, "" as t,Sum([sheet1].[Value])AS ValueAll FROM sheet1 GROUP BY sheet1.Year & " 小计"

UNION ALL select "总计", "" as t,sum(Value) from sheet1 ORDER BY Year;

TA的精华主题

TA的得分主题

发表于 2005-4-22 10:44 | 显示全部楼层

TA的精华主题

TA的得分主题

 楼主| 发表于 2005-4-25 16:00 | 显示全部楼层

我怎么做不出来呀?帮忙看看错在哪里?

老提示:在联合查询中所选定的两个数据表或查询中的列数不匹配.

我想按"存档月份"小计,"存档年"总计

谢谢!

OoisHddJ.rar (42.3 KB, 下载次数: 11)

TA的精华主题

TA的得分主题

发表于 2005-4-26 10:10 | 显示全部楼层

SELECT [Contract and Revenue(2002-2005)].[存档年Year], [Contract and Revenue(2002-2005)].[存档季Quarter], [Contract and Revenue(2002-2005)].[存档月份Month], [Contract and Revenue(2002-2005)].[区域/Area], [Contract and Revenue(2002-2005)].[客户编号/Subscriber Code], [Contract and Revenue(2002-2005)].[合同编号/ Contract Number], [Contract and Revenue(2002-2005)].[客户名称/ Subscriber Name], [Contract and Revenue(2002-2005)].[席位/小时License/Hour], [Contract and Revenue(2002-2005)].[月数/Months], [Contract and Revenue(2002-2005)].[合同金额/Contract Value], [Contract and Revenue(2002-2005)].[签约人/Handled By], [Contract and Revenue(2002-2005)].[开始日期Star Date], [Contract and Revenue(2002-2005)].[结束日期End Date], [Contract and Revenue(2002-2005)].[存档日期], [Contract and Revenue(2002-2005)].[回款金额Accepted], [Contract and Revenue(2002-2005)].[待收金额 Due], [Contract and Revenue(2002-2005)].[坏账Dead], [Contract and Revenue(2002-2005)].[备注 Remark] FROM [Contract and Revenue(2002-2005)]; union all

SELECT [Contract and Revenue(2002-2005)].[存档月份Month] & " 小计" AS 表达式1, "" as t1,"" as t2,"" as t3,"" as t4,"" as t5,"" as t6,"" as t7,"" as t8,"" as t9,"" as t10,"" as t11,"" as t12,"" as t13,"" as t14,"" as t15,"" as t16,Sum([Contract and Revenue(2002-2005)].[合同金额/Contract Value])AS ValueAll FROM [Contract and Revenue(2002-2005)] GROUP BY [Contract and Revenue(2002-2005)].[存档月份Month] & " 小计"

UNION ALL select "总计", "" as t1,"" as t2,"" as t3,"" as t4,"" as t5,"" as t6,"" as t7,"" as t8,"" as t9,"" as t10,"" as t11,"" as t12,"" as t13,"" as t14,"" as t15,"" as t16,sum([合同金额/Contract Value]) from [Contract and Revenue(2002-2005)] ORDER BY [存档年Year];

TA的精华主题

TA的得分主题

 楼主| 发表于 2005-4-26 15:23 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
"" as t1,"" 能解释一下是什么意思吗?

TA的精华主题

TA的得分主题

 楼主| 发表于 2005-4-26 15:26 | 显示全部楼层

TA的精华主题

TA的得分主题

 楼主| 发表于 2005-4-26 15:27 | 显示全部楼层

试了,完全不对呀

明细

此月小计

明细

此月小计

可做出来是乱的

我哭求我要求的结果!

您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

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

GMT+8, 2024-11-15 12:37 , Processed in 0.043676 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

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

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

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