title: Select highest bid in table with multiple rows
body: <p>I'm working with a <code>bids</code> table for a marketplace and am trying to get the highest bids of a user. A user is able to bid multiple times (with increasing amounts), therefore I only want the highest bid for each listing item.</p>
  
  <pre><code>+----+------------+---------+--------+
  | id | listing_id | user_id | amount |
  +----+------------+---------+--------+
  |  1 |          1 |       1 |      5 |
  |  2 |          2 |       1 |     10 |
  |  3 |          2 |       1 |     15 |
  +----+------------+---------+--------+
  </code></pre>
  
  <p>I'd like the end result to be:</p>
  
  <pre><code>+----+------------+---------+--------+
  | id | listing_id | user_id | amount |
  +----+------------+---------+--------+
  |  1 |          1 |       1 |      5 |
  |  3 |          2 |       1 |     15 |
  +----+------------+---------+--------+
  </code></pre>
  
  <p>I've tried the following query:</p>
  
  <pre><code>select bids.id, bids.listing_id, bids.user_id, max(bids.amount) as amount 
  from bids 
  group by listing_id;
  </code></pre>
  
  <p>But this gives me the following (to me) strange result:</p>
  
  <pre><code>+----+------------+---------+--------+
  | id | listing_id | user_id | amount |
  +----+------------+---------+--------+
  |  1 |          1 |       1 |      5 |
  |  2 |          2 |       1 |     15 |
  +----+------------+---------+--------+
  </code></pre>
  
  <p>Amount 15 is correct, but ID=2 is from the record with amount=10.
  How do I get the correct result with record id=1 and id=3?</p>