title: MySql select top 3 results from each country
body: <p>Here be my problem ... (very grateful for any advice from the MySql experts out there)</p>
  
  <p>I have a database table specifying:<br><br>
  time (9.99, 10.96, 11.02 etc..)<br>
  country (eg JAM, USA, CAN ect..)<br>
  date (eg. 2011, 2012, 2013 etc..)</p>
  
  <p>I wish to display a ranking list ordered by time (ASC) for a specified year (2012)</p>
  
  <p>The catch - I only want to show a maximum of three entries per country and the list must be ordered by time (ASC)</p>
  
  <p>I have tried (from another suggestion on here):</p>
  
  <pre><code>set @num := 0, @country := '';
  select country, time
  from (
  select country, time,
    @num := if(@country = country, @num + 1, 1) as row_number,
    @country := country as dummy
  from stats
  
  where eventID = 1
  order by country
  ) as x where x.row_number &lt;= 3;
  </code></pre>
  
  <p>However, this works to a degree - but it orders the list by country (alphabetical).</p>
  
  <p>Apologies if this is to vague .. but would love some ideas!!!</p>
  
  <p>many thanks in advance!</p>