title: Why ORDER BY + MAX() return the maximum value when I grouping?
body: <p>I have this part of a query :</p>
  
  <pre><code>GROUP BY trackid 
  ORDER BY MAX(history.date) DESC
  </code></pre>
  
  <p>And I see that, when I grouping, it returns the row with maximum date for each group. Why this behaviour? Order should works on the whole rows...not on the grouping ?!?!?</p>
  
  <p><strong>EDIT</strong> (Example)</p>
  
  <p>This is my whole query :</p>
  
  <pre><code>SELECT tracklist.value, history.date
  FROM history JOIN tracklist ON history.trackid=tracklist.trackid 
  ORDER BY history.date DESC
  </code></pre>
  
  <p>The result is :</p>
  
  <pre><code>tracklist3  2011-04-27 15:40:36
  tracklist2  2011-04-27 13:15:43
  tracklist2  2011-04-02 00:30:02
  tracklist2  2011-04-01 14:20:12
  tracklist1  2011-03-02 14:13:58
  tracklist1  2011-03-01 12:11:50
  </code></pre>
  
  <p>As you can see, all line is correctly ordered by history.date.
  Now I'd like to group them, keeping for each group the row with MAX history.date. 
  So the output should be :</p>
  
  <pre><code>tracklist3  2011-04-27 15:40:36
  tracklist2  2011-04-27 13:15:43
  tracklist1  2011-03-02 14:13:58
  </code></pre>
  
  <p>I see that :</p>
  
  <pre><code>GROUP BY trackid 
  ORDER BY MAX(history.date) DESC
  </code></pre>
  
  <p>works correctly, but I really don't understand why it works :) Order by is for the whole rows, not for the grouping....</p>