Когда я запускаю простой запрос, где AskiaID представляет собой поле числового c, в MS SQL Server Management Studio я получаю следующее: -
SELECT TaskResult, [80444], [80421], [80438], [80435], [80046], [80427], [80378], [80442], [80419], [80436], [80379], [80410], [80439], [80437], [80405], [80377], [80383], [80406], [80420], [80443] FROM [RSM.Statistics].[dbo].[Statistic_Call] as PivotData
PIVOT
(
COUNT(TaskResult)
FOR RTRIM(CAST(AgentID AS CHAR)) IN ([80444], [80421], [80438], [80435], [80046], [80427], [80378], [80442], [80419], [80436], [80379], [80410], [80439], [80437], [80405], [80377], [80383], [80406], [80420], [80443])
) AS PivotResult
Msg 102, Level 15, State 1, Line 5
Incorrect syntax near '('.
Если я изменяю запрос на его оригинальная форма: -
SELECT TaskResult, [80444], [80421], [80438], [80435], [80046], [80427], [80378], [80442], [80419], [80436], [80379], [80410], [80439], [80437], [80405], [80377], [80383], [80406], [80420], [80443] FROM [RSM.Statistics].[dbo].[Statistic_Call] as PivotData
PIVOT
(
COUNT(TaskResult)
FOR AgentID IN (80444, 80421, 80438, 80435, 80046, 80427, 80378, 80442, 80419, 80436, 80379, 80410, 80439, 80437, 80405, 80377, 80383, 80406, 80420, 80443)
) AS PivotResult
Msg 102, Level 15, State 1, Line 5
Incorrect syntax near '80444'.
Есть идеи, что я делаю не так?