请问,我正试图调整这些数据,我的代码出了什么问题?我一直收到错误 - ')'
附近的语法不正确SourceQuery:
CategoryID AVGUnitPrice
1 37.98
2 23.06
3 25.16
4 28.73
5 20.25
6 54.01
7 32.37
8 20.68
SELECT CategoryID AS PerCategory,[1],[2],[3],[4],[5],[6],[7],[8]
FROM
(SELECT CategoryID, AVG(UnitPrice) FROM Dbo.Products GROUP BY CategoryID) AS SourceQuery
PIVOT (AVG(UnitPrice))
FOR CategoryID
IN ([1],[2],[3],[4],[5],[6],[7],[8])
AS Pivot1
ORDER BY CategoryID;
答案 0 :(得分:0)
应该是
SELECT SourceQuery.CategoryID AS PerCategory,[1],[2],[3],[4],[5],[6],[7],[8]
FROM
(SELECT CategoryID, AVG(UnitPrice) UnitPrice
FROM Dbo.Products GROUP BY CategoryID)
AS SourceQuery
PIVOT (AVG(UnitPrice)
FOR CategoryID
IN ([1],[2],[3],[4],[5],[6],[7],[8])
)
AS Pivot1
ORDER BY PerCategory;
答案 1 :(得分:0)
试试这个:
SELECT CategoryID AS PerCategory,[1],[2],[3],[4],[5],[6],[7],[8]
FROM
(SELECT CategoryID, AVG(UnitPrice) FROM Dbo.Products GROUP BY CategoryID) AS SourceQuery
PIVOT (AVG(UnitPrice) FOR CategoryID IN ([1],[2],[3],[4],[5],[6],[7],[8]))
AS Pivot1
ORDER BY CategoryID;
答案 2 :(得分:0)
model.make_params()