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