我使用以下SQL来透视1.文本值和2.日期值 但返回Microsoft SQL Server错误
消息8624,第16层,状态17,第1行
内部查询处理器错误:查询处理器无法生成 查询计划。有关更多信息,请联系客户支持服务。
有帮助吗?
SELECT
occurrence,KeyObject,KeyNumb,ProcessStartDate,Reference,ProcessNo,
[forename] AS Forename, [surname] AS Surname, [TenLetDate] as TenLetDate
FROM
(SELECT
LGOVProcessData.ProcessNo
,LGOVProcessData.occurrence
,LGOVProcessDataItems.FieldName AS Fieldname
,LGOVProcessDataItems.FieldName AS Fieldname2
,LGOVProcessDataItems.strValue
,LGOVProcessDataItems.dateValue
,LGOVProcessData.DataID
,W2Process.KeyObject
,W2Process.KeyNumb
,W2Process.ProcessNo AS 'W2ProcessProcessNo'
,W2Process.ProcessStartDate
,W2Process.Reference
FROM
LGOVProcessData
INNER JOIN LGOVProcessDataItems
ON LGOVProcessData.DataID = LGOVProcessDataItems.DataID
INNER JOIN W2Process
ON LGOVProcessData.ProcessNo = W2Process.ProcessNo
WHERE
LGOVProcessData.TemplateID = 5299
) ps
PIVOT
(
MAX(strValue)
FOR
FieldName IN
([forename], [surname]
) as pvt
PIVOT
(
MAX(dateValue)
FOR
FieldName2 IN
([TenLetDate])
) as pvt