title: MySQL SUM does not work with GROUP BY
body: <p>I have these tables</p>
  
  <p><img src="https://i.stack.imgur.com/0hbsf.png" alt="customers table"></p>
  
  <p><img src="https://i.stack.imgur.com/noRgL.png" alt="products table"></p>
  
  <p><img src="https://i.stack.imgur.com/857Xa.png" alt="purchases table"></p>
  
  <p><img src="https://i.stack.imgur.com/bATee.png" alt="versions table"></p>
  
  <p>When I execute this query </p>
  
  <pre><code>SELECT 
      products.name,
      versions.version, 
      purchases.`purchase date`, 
      SUM(purchases.`number of licenses`) 
  FROM products,
      versions, 
      purchases 
  WHERE 
      products.id = versions.`product id` 
      AND products.id = 1
  GROUP BY
      products.name, 
      versions.version;
  </code></pre>
  
  <p>I get this result: </p>
  
  <p><img src="https://i.stack.imgur.com/zlAtG.png" alt="enter image description here"></p>
  
  <p>Where number of licences is the total sum of purchases in the table, when I expect only 20 (with product id = 1, that is rows 8, 10, 11) instead of 54.</p>
  
  <p>Could someone help me with this, please?</p>