|
这个查询在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.省市代码" |
|