title: Different result after joining new table
body: <p>My fiddle is <a href="https://www.db-fiddle.com/f/mALNg1YXoWJhf1Wbdmhekz/5" rel="nofollow noreferrer">here</a></p>
  <p>I tried to repair the second query and return the same result as in the first query because products with id in <code>(1,2,3,4,5)</code> are all available products, so the results should be the same.</p>
  <p>Why am I getting different results in the second query? How can I repair it?</p>
  <p>Basically, I want to check what is the total ad_spend during each month for all ads (first query) and for ads which has assigned certain products (second query)</p>
  <p>My first query(which return correct result):</p>
  <pre><code>select min(DATE_FORMAT(ai.date,&quot;%m-%Y&quot;)) as date, ROUND(SUM(ai.ad_spend)) as total_ad_spend
                  from ad_insight ai 
                  group by YEAR(ai.date), MONTH(ai.date) 
                  order by ai.date asc;
  </code></pre>
  <p>My second query(which return incorrect result):</p>
  <pre><code>select DATE_FORMAT(ai.date, '%m-%Y') as mmyy,
    MIN(ai.date) as min_date,
    ROUND(SUM(ai.ad_spend)) as total_ad_spend
  from ad_insight as ai
  join ads_products as ap on ai.ad_id = ap.ad_id
  where ap.product_id in (1,2,3,4, 5)
  group by mmyy
  order by min_date
  </code></pre>