Office中国论坛/Access中国论坛
标题:
[求助]交叉查询问题
[打印本页]
作者:
xinger
时间:
2005-9-8 19:59
标题:
[求助]交叉查询问题
strsql = "TRANSFORM Sum([销售记录表].[销售数量]) AS 销售数量之Sum " & "SELECT [销售记录表].[销售商], Sum([销售记录表].[销售数量]) AS [总计 销售数量] " & "FROM 销售记录表 " & "GROUP BY [销售记录表].[销售商] " & "
IVOT [销售记录表].[省份];"
CurrentProject.Connection.Execute "drop view 销售记录表_交叉表行业"
CurrentProject.Connection.Execute "create view 销售记录表_交叉表行业 as " & strsql
DoCmd.OpenQuery "销售记录表_交叉表行业"
CurrentProject.Connection.Close
运行会出现"无效的SQL句法,需要符号:select" ,应该是那个strsql语句的问题,但这个语句是从查询转换过来的,应该没错.到底是怎样?????????
作者:
xinger
时间:
2005-9-8 22:28
有点明白是什么问题, 好象是不支持 TRANSFORM…… PIVOT语句的。
但是换了一种形式,也是实现交叉表的
SELECT 销售商,
SUM(CASE 省份 WHEN '北京' THEN 销售数量 ELSE NULL END) AS [北京],
SUM(CASE 省份 WHEN '广东' THEN [销售数量] ELSE NULL END) AS [广东],
SUM(CASE 省份 WHEN '河北' THEN [销售数量] ELSE NULL END) AS [河北]
FROM 销售记录表 GROUP BY [销售商];
会出错,操作符丢失。到底该怎么写???
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/)
Powered by Discuz! X3.3