-1
SELECT *
FROM
(SELECT
datename(month, [date]) as [Month],
planttype,
(sum(noof50kgsbags * 50))[Total Kgs]
FROM
K_FP_Indent
WHERE
(date BETWEEN '2013-04-01 00:00.000' AND getdate())
AND (attrited = 'True')
GROUP BY
datename(month, [date]), month([date]), planttype,[date]) as s
PIVOT
(
SUM([Total Kgs])
FOR [planttype] IN (A,B,C,D)
) AS s2
如何使用order by語句查詢此查詢?我知道,我們不能爲嵌入式查詢使用數據透視表排序
輸出使用命令:
Month A B C D
April x X X X
August X X X X
July X X X X
期望中的OP
Month A B C D
April x X X X
July X X X X
August X X X X
它顯示瞭如「多部分標識符的錯誤「月亮」不能被束縛。「 – Bhagavan
請給我幾分鐘時間:) – Devart
@ ajmalmhd04 - 'ORDER BY子句在視圖,內聯函數,派生表,子查詢和公用表表達式中無效,除非還指定了TOP,OFFSET或FOR XML。' – Devart