title: Select top rows from each group
body: <p>I have to retrieve the top rows from each group, based on the max values of two columns.</p>
  
  <p>This is the table:</p>
  
  <pre><code>tag_series_id   |   tag_season_num  |   tag_episode_num
  269653              2                   24
  269653              3                   1
  269653              3                   2
  269653              3                   3   
  281593              1                   9
  281593              1                   11
  281593              1                   10
  </code></pre>
  
  <p>The result set should be the record with the maximum <code>tag_season_num</code> and <code>tag_episode_num</code>.   <code>tag_season_num</code> should be higher priority.</p>
  
  <p>The result set should be this:</p>
  
  <pre><code>tag_series_id   |   tag_season_num  |   tag_episode_num
  269653              3                   3   
  281593              1                   11
  </code></pre>
  
  <p>These are some of my failed attempts:</p>
  
  <pre><code>SELECT tag_series_id, tag_season_num, tag_episode_num, tag_watch_status
  FROM taggedshows WHERE 
  GROUP BY tag_series_id, tag_season_num
  ORDER BY tag_season_num desc, tag_episode_num desc;
  
  SELECT tag_series_id, tag_season_num, tag_episode_num 
  FROM (SELECT * from taggedshows
  ORDER BY tag_series_id, tag_season_num desc, tag_episode_num desc) x
  GROUP BY tag_series_id;
  
  SELECT tag_series_id, MAX(tag_season_num), MAX(tag_episode_num)
  FROM taggedshows
  GROUP BY tag_series_id;
  </code></pre>