title: MySQL SUM(column) + (SUBQUERY WITH SUM)
body: <p>I want to make a query that adds up points for a team. The points are added up by doing SUM on a column + a SUM from another table with the same team-id. I try to write it like this: </p>
  
  <pre><code>SELECT 
      k.id, 
      s.fylke, 
      s.Kommune, 
      s.Skolenavn, 
      k.schoolid, 
      k.number, 
      k.letter, 
      SUM(e.amount) + (SELECT SUM(poeng) FROM oppdrag WHERE klasseid=k.id ) AS poeng 
  FROM skoler AS s, klasser AS k, etappe AS e 
  WHERE s.id=k.schoolid AND k.id=e.klasseid AND e.year='2016'
  GROUP BY k.id 
  ORDER BY poeng
  </code></pre>
  
  <p>The problem is that, when I write it in this fashion, it gives correct amount of points if the team has an entry in table "oppdrag" otherways it just returns NULL as points (poeng).</p>