title: MySQL: Selecting MAX value and grouping
body: <p>This is what I have now in my query:</p>
  
  <pre><code>+--------------------+-----------+------------+
  | status             | entity_id | seconds    |
  +--------------------+-----------+------------+
  | Submitted          |       494 | 1352102400 |
  | Accepted           |       494 | 1352275200 |
  | In press/e-publish |       494 | 1352966400 |
  | Rejected           |       520 | 1355817600 |
  | Accepted           |       570 | 1352102400 |
  +--------------------+-----------+------------+
  </code></pre>
  
  <p>I want it to look like:</p>
  
  <pre><code>+--------------------+-----------+------------+
  | status             | entity_id | seconds    |
  +--------------------+-----------+------------+
  | In press/e-publish |       494 | 1352966400 |
  | Rejected           |       520 | 1355817600 |
  | Accepted           |       570 | 1352102400 |
  +--------------------+-----------+------------+
  </code></pre>
  
  <p>In quasi-SQL:</p>
  
  <pre><code>SELECT status, entity_id, MAX(seconds) 
  FROM foo
  GROUP BY entity_id, seconds
  </code></pre>
  
  <p>The above quasi-SQL looks correct, but the "status" column value does not correspond to the correct row.  I get back something like the below:</p>
  
  <pre><code>+--------------------+-----------+------------+
  | status             | entity_id | seconds    |
  +--------------------+-----------+------------+
  | Submitted          |       494 | 1352966400 |
  | Rejected           |       520 | 1355817600 |
  | Accepted           |       570 | 1352102400 |
  +--------------------+-----------+------------+
  </code></pre>