当完全相同的查询运行良好时,PIVOT函数无法从SQLCMD中运行 来自SSMS 从sqlcmd运行的SQL Server 2008版。在PIVOT附近给出语法错误
我将查询放入.sql文件中,并通过sqlcmd的-i选项提供该查询。否
SELECT * FROM (
SELECT
ROW_NUMBER() OVER(PARTITION BY EMP-ID,Date order by EMP-ID ) AS rno,
EMP-ID,Date, EMP-CAT
FROM DB.table1
where EMP-CAT != 'XXX'
) as L
PIVOT
(
MAX(EMP-CAT)
FOR rno IN ("1","2","3")
)AS pvt1