设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 1008|回复: 2
打印 上一主题 下一主题

[查询] 问题出在哪儿?(在线急等)

[复制链接]
跳转到指定楼层
1#
发表于 2007-8-24 16:54:16 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
这个查询在Access里没有问题,但是在vb.net上报错。请高手指教!!
(我试过,把下面的查询减少一部分就能正常运行)

下面的查询在Access上能够正常运行:
SELECT c1.省市代码 AS 代码, c1.省市, c1.站数量, c1.额度, iif(not isnull([买入数量]),[买入数量],0) AS 买入总数, iif(not isnull([卖出数量]),[卖出数量],0) AS 卖出总数, iif(not isnull([预定数量]),[预定数量],0) AS 预定总数, [卖出总数]/[额度] AS 卖出率
FROM (([SELECT station_info.province AS 省市, Left([station_num],2) AS 省市代码, Count(station_info.station_num) AS 站数量, Sum(station_info.amount) AS 额度
FROM station_info
GROUP BY station_info.province, Left([station_num],2)]. AS c1 LEFT JOIN [SELECT station_info.province AS 省市, Count(customer_info_43.yytime) AS 买入数量
FROM station_info LEFT JOIN customer_info_43 ON station_info.station_num=customer_info_43.station_num
WHERE ((Not (customer_info_43.yytime) Is Null))
GROUP BY station_info.province]. AS c2 ON c1.省市 = c2.省市) LEFT JOIN [SELECT station_info.province AS 省市, Count(customer_info_43.jctime) AS 卖出数量
FROM station_info LEFT JOIN customer_info_43 ON station_info.station_num = customer_info_43.station_num
WHERE ((Not (customer_info_43.jctime) Is Null))
GROUP BY station_info.province]. AS c3 ON c1.省市 = c3.省市) LEFT JOIN [SELECT station_info.province AS 省市, Count(customer_info_43.hftime) AS 预定总数
FROM station_info LEFT JOIN customer_info_43 ON station_info.station_num = customer_info_43.station_num
WHERE ((Not (customer_info_43.hftime) Is Null))
GROUP BY station_info.province]. AS c4 ON c1.省市 = c4.省市
ORDER BY c1.省市代码;

下面的查询时将上面的代码copy下来,什么都没动,加了连接符,去掉末尾的";"号
strsql="SELECT c1.省市代码 AS 代码, ……= customer_info_43.station_num " &  _
"WHERE ((Not (customer_info_43.jctime) Is Null)) ……ORDER BY c1.省市代码"
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2007-8-24 17:04:54 | 只看该作者
ACCESS的SQL 跟VB.NET 的SQL是不样的
3#
 楼主| 发表于 2007-8-24 17:17:53 | 只看该作者

回复 #2 andymark 的帖子

这我知道,比如nz,我已经改成iif,缩短查询后,保留嵌套2个子查询,能够通过。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-11-12 15:00 , Processed in 0.091188 second(s), 27 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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