Categories
Development

Get totals of each month a year including the month with no result

I want to echo the total of invoices created per month. Code below is working so far but I need a 0 if there is no result in a month. $sql = “SELECT MONTH( invoice_date ) AS MONTH, SUM(`invoice`.`total`) as total FROM `invoices` WHERE YEAR(invoice_date) = ‘2019’ GROUP BY MONTH(invoice_date)”; $result = mysqli_query($con,$sql); while($data = […]