【发布时间】:2018-11-24 15:04:58
【问题描述】:
这是我所拥有的:
SELECT DATENAME(month, PurchaseDate) PurchaseMonth
, CASE WHEN DATENAME(month, PurchaseDate) is null then 'Grand Total'
ELSE coalesce (PurchaseType,'Monthly Total') end AS PurchaseType
, Sum(PurchaseAmt) as SummorizedPurchaseAmt
FROM tPurchaseItem
GROUP BY ROLLUP(DATENAME(month, PurchaseDate), PurchaseType);
这有效,但不按时间顺序排序。
结果是这样的:
我希望订单是一月、二月等。
【问题讨论】:
标签: sql sql-server