我有一个查询,按月提供总销售额。但是,有些月份没有销售。我如何在查询结果中获得该月的 0 值?
SELECT
p.Part,
SUM(s.Sales) AS Sales,
MONTH(s.SalesDate) AS Month_Sold
FROM
Parts p
LEFT OUTER JOIN Sales s ON p.Part = s.Part
GROUP BY
p.Part,
MONTH(s.SalesDate)
ORDER BY
p.Part,
Month_Sold