coalesce
के साथ प्रयास करें फ़ंक्शन जो '0' लौटाएगा यदि sum(orders.amount)
एक विशिष्ट महीने के लिए शून्य है:
select COALESCE(sum(o.amount), 0) as amount, o.completed_at
from orders o
where date(o.completed_at) between '2011/10/01' and '2012/03/06'
group by year(o.completed_at), month(o.completed_at) order by o.completed_at