title: MySQL: Conditional MIN() with GROUP BY
body: <p>I have this table called <code>times</code> where I record race information for a racing game:</p>
  <pre><code>race_id     map     name    time
  30509       desert  Peter   12.68
  30510       desert  Jakob   10.72
  30511       desert  Peter   18.4
  30512       jungle  Peter   39.909
  30513       jungle  Peter   39.84
  30514       desert  Harry   16.129
  30515       space   Harry   774.765
  30516       jungle  Jonas   46.047
  30517       city    Jonas   23.54
  30518       city    Jonas   23.13
  30519       desert  Mike    22.9
  30520       space   Fred    174.244
  </code></pre>
  <p>I have two questions. How would I best go about:</p>
  <ol>
  <li>Finding the lowest time (world record) on a given map?</li>
  </ol>
  <p>I have tried this query:</p>
  <pre><code>SELECT *, MIN(time) FROM times WHERE map = 'desert';
  </code></pre>
  <p>This yields a seemingly incorrect arbitrary row with an added column called <code>MIN(time)</code> where the correct lowest time is.</p>
  <ol start="2">
  <li>Finding the lowest time on all maps, but <strong>only</strong> if it's done by a certain player (find all world records by given player)?</li>
  </ol>
  <p>For this I have tried this query:</p>
  <pre><code>SELECT *, MIN(time) FROM times WHERE name = 'Peter' GROUP BY map;
  </code></pre>
  <p>This seems to only return the first row by the given name for each map, regardless if it's the lowest time or not.</p>
  <p>I'm fairly new to SQL(MySQL), so I might be missing something obvious here. I've been looking around for quite a while now, and any help would be greatly appreciated. Thanks!</p>