title: Using ORDER BY and GROUP BY together
body: <p>My table looks like this (and I'm using MySQL):</p>
  <pre><code>m_id | v_id | timestamp
  ------------------------
  6    |   1  | 1333635317
  34   |   1  | 1333635323
  34   |   1  | 1333635336
  6    |   1  | 1333635343
  6    |   1  | 1333635349
  </code></pre>
  <p>My target is to take each m_id one time, and order by the highest timestamp.</p>
  <p>The result should be:</p>
  <pre><code>m_id | v_id | timestamp
  ------------------------
  6    |   1  | 1333635349
  34   |   1  | 1333635336
  </code></pre>
  <p>And i wrote this query:</p>
  <pre><code>SELECT * FROM table GROUP BY m_id ORDER BY timestamp DESC
  </code></pre>
  <p>But, the results are:</p>
  <pre><code>m_id | v_id | timestamp
  ------------------------
  34   |   1  | 1333635323
  6    |   1  | 1333635317
  </code></pre>
  <p>I think it causes because it first does GROUP_BY and then ORDER the results.</p>
  <p>Any ideas? Thank you.</p>