📜  在 sql 代码示例中按月排序

📅  最后修改于: 2022-03-11 15:05:11.984000             🧑  作者: Mango

代码示例1
SELECT     { fn MONTHNAME(OrderDate) } AS MonthName, YEAR(OrderDate) AS Year, SUM(TotalValue) AS Profits
FROM         [Order]
WHERE     (YEAR(OrderDate) = @year)
GROUP BY { fn MONTHNAME(OrderDate) }, MONTH(OrderDate), YEAR(OrderDate)
order by Year(orderDate),month(OrderDate)