从SQL语法访问PIVOT

时间:2014-09-04 15:05:47

标签: c# sql ms-access-2003

我正在使用Access,我正在尝试复制我在SQL中使用的相当复杂的数据透视表,并且它似乎在语法中遇到了FROM语句的问题。

SELECT r.resourceName AS 'Resource Name', 
    p.projectNumber AS 'Project Number', 
    p.projectName AS 'Project Name', 
    p.projectSystem AS 'Project System', 
    a.resourceProjRole AS 'Resource Role', 
    p.projectManager AS 'Project Manager', 
    a.allocDescription AS 'Description', 
    a.[Sep 2014], a.[Oct 2014], 
    a.[Nov 2014], a.[Dec 2014]
FROM Projects p, Resources r 
JOIN (SELECT * FROM allocation a 
PIVOT (SUM(allocationValue) 
FOR AllocationMonth IN ([Sep 2014], [Oct 2014], [Nov 2014], [Dec 2014] )) PVT ) a 
ON (r.resourceName = a.resourceName)WHERE p.projectName = a.projectName ORDER BY r.resourceName, a.projectName

这是我到目前为止所管理的

TRANSFORM SUM(Allocation.AllocationValue)
SELECT Allocation.ProjectName
FROM Allocation
GROUP BY Allocation.ProjectName
PIVOT Allocation.AllocationMonth IN ('June, 2014', 'July, 2014')

这有点起作用,因为它按月列出值,但我需要它按资源名称分解,现在它只根据项目计算所有值。

0 个答案:

没有答案