title: Create hiscore list from hiscore table
body: <p>I want to create hiscore list, but I have trouble doing it. This is my hiscore table and for every game I write user score into this table.</p>
  
  <p>This is how my hiscore table look like:</p>
  
  <pre><code>id    user_id    user_name    score    entry_date
  -----------------------------------------------------------
  1      1         tom          500      2012-06-05 14:30:00
  2      1         tom          500      2012-06-05 10:25:00
  3      2         jim          300      2012-06-05 09:20:00
  4      2         jim          500      2012-06-05 09:22:00
  5      3         tony         650      2012-06-05 15:45:00
  </code></pre>
  
  <p>I want to get first 3 MAX scores, but I have to make sure if they have same score then I should take score that is first entered (based on <code>entry_date</code> column)</p>
  
  <p>The query returned should be something like this.</p>
  
  <pre><code>1.  3      tony     650      2012-06-05 15:45:00     &lt;- hi have to be first, because he have top score
  2.  2      jim      500      2012-06-05 09:22:00     &lt;- jim have the same score as tom, but he make that score before tom did so he is in second place
  3.  1      tom      500      2012-06-05 10:25:00     &lt;- tom have 2 entries with the same score, but we only take the one with smallest date
  </code></pre>
  
  <p>This is SQL query that I wrote but with that query i am getting hiscore list but it's not ordered by entry_date and I don't have any idea how to solve this problem.</p>
  
  <pre><code>SELECT TOP 3
      hiscore.user_id,
      hiscore.user_name,
      MAX(hiscore.score) AS max_score,
  FROM
      hiscore
  GROUP BY
      hiscore.user_id, hiscore.user_name
  ORDER BY
      max_score DESC
  </code></pre>
  
  <h2>UPDATE: Regarding score sum question</h2>
  
  <p>Regarding score sum, I need query that will return this when querying original hiscore table:</p>
  
  <pre><code>user_id   user_name    score
  --------------------------------
  1          Tom        1000
  2          Jim         800
  3          Tony        650
  </code></pre>
  
  <p>And if there are two users with the same score sum, user with better rank is the one with less entries in hiscore table.</p>