我有一個熱膨脹係數如下PIVOT對公共表表達式
WITH details
AS (SELECT FldId
,Rev
,Words
,row_number() OVER (PARTITION BY FldId ORDER BY Rev DESC) AS rn
FROM WorkItemLongTexts
WHERE ID = 2855
)
SELECT f.ReferenceName
,d.FldId
,Rev
,Words
FROM details AS d
INNER JOIN Fields AS f ON f.FldId = d.FldId
WHERE d.rn = 1 ;
以上返回以下輸出
ReferenceName | FldId | Rev | Words
Description 52 2 Description here
Objectives 10257 2 Objectives here
Specification 10258 6 Specification here
Requirements 10259 6 Requirements here
我想申請PIVOT(或什麼是最好的選擇),這樣我可以得到如下輸出
Description | Objectives | Specification | Requirements
這裏描述 個 目標位置 規格這裏 要求這裏
PLS。建議。
感謝
得到錯誤 「操作數的數據類型NTEXT是最大操作無效。」 – stackoverflowuser
你可以投到nvarchar(max)嗎? ntext已棄用。 –
'... THEN CAST([Words] AS nvarchar(max)')而不是'THEN [Words]';或者nvarchar(4000)如果4000足夠的話 –