I want to generate a report that sums up all my invoices per month over a year.
But, if I had a month without any invoices, I will not get an entry for that month,
whereas I want to have a line with zeroes.
Anyone been into this issue before?
SELECT mon_month, (SELECT sum(inv_total)
FROM invoices
WHERE months.month_id = MONTH(inv_start)
AND inv_start
BETWEEN '2013-01-01'
AND '2013-12-31'
)
FROM months
GROUP BY mon_month
ORDER BY mon_id