我正在使用Access并尝试复制我在MSDN上找到的一些语法。不幸的是,似乎Access在我的语法中遇到了FROM语句的问题。我不确定为什么。
SELECT YEAR, HC
FROM
(
SELECT [Retention & Graduation].Year, [Retention & Graduation].Status, [Retention & Graduation].Hc
FROM [Retention & Graduation]
) AS X
PIVOT
(
SUM([HC]) FOR [STATUS] IN ([GONE], [HERE], [GRAD])
) AS Xx
答案 0 :(得分:6)
在MS Access中进行透视的语法与sql server不同。您必须使用TRANSFORM
功能来转移数据。
语法类似于:
TRANSFORM SUM([Retention & Graduation].Hc)
SELECT [Retention & Graduation].Year,
[Retention & Graduation].Status,
[Retention & Graduation].Hc
FROM [Retention & Graduation]
GROUP BY [Retention & Graduation].Year
PIVOT [Retention & Graduation].[STATUS]