title: Select MAX value with restriction to rows
body: <p>I have 3 tables:</p>
  
  <p>matchdays:</p>
  
  <pre><code>matchday_id | season_id | userid | points | matchday
  ----------------------------------------------------
  1           |  1        | 1      | 33     | 1
  2           |  1        | 2      | 45     | 1
  etc
  </code></pre>
  
  <p>players</p>
  
  <pre><code>userid | username
  -----------------
  1      | user1
  2      | user2
  etc.
  </code></pre>
  
  <p>seasons</p>
  
  <pre><code>seasons_id  | title  | userid
  ----------------------------
  1           | 2011   | 3
  2           | 2012   | 10
  3           | 2013   | 5
  </code></pre>
  
  <p>My query:</p>
  
  <pre><code>SELECT s.title, p.username, SUM(points) FROM matchdays m
  INNER JOIN players p ON p.userid = m.userid
  INNER JOIN seasons s ON m.userid = s.userid
  group by s.season_id
  </code></pre>
  
  <p>This results in (example!):</p>
  
  <pre><code>title | username | SUM(points)
  ------------------------------
  2011  | user3    | 3744
  2012  | user10   | 3457
  2013  | user5    | 3888
  </code></pre>
  
  <p>What it should look like is a table with the winner (max points) of every season. Right now, the title and username is correct, but the sum of the points is way too high. I couldn't figure out what sum is calculated. Ideally, the sum is the addition of every matchday of a season for every user. </p>