title: MYSQL select sum by months including with null values
body: <p>I'm working on a mysql request that make the sum of values by months including those with null values.
  The request result send only the first line without making the sum operation.</p>
  <pre><code>SELECT SUM(IFNULL(t1.sub_total,0)) AS amount, 
         am.a_month AS date
  FROM (
          SELECT ifnull(vn.sub_total,0) as sub_total,
                 cast(DATE_FORMAT(order_date, '%M') as char) as mdate
          FROM orders_new vn
          WHERE order_status = 1
          AND order_date BETWEEN '2022-01-01' AND '2022-12-31' 
          GROUP BY DATE_FORMAT(order_date, '%M')
        ) t1 
  RIGHT OUTER JOIN all_months am on t1.mdate = am.a_month
  group by am.a_month
  order by a_month_id asc;
  </code></pre>
  <p>result
  <a href="https://i.stack.imgur.com/yj5Wf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yj5Wf.png" alt="enter image description here" /></a></p>
  <p>below the source table
  <a href="https://i.stack.imgur.com/lnlOT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lnlOT.png" alt="enter image description here" /></a></p>