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 ステートメントを使用するにはどうすればよいですか? インライン クエリに 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