title: MySQL group by last entry
body: <p>My table payment_status have these fields:</p>
  
  <ul>
  <li>id</li>
  <li>payment_id</li>
  <li>status</li>
  <li>created</li>
  <li>created_by</li>
  </ul>
  
  <p>Many entries could have the same payment_id... So, I want to get the last status for one payment_id...</p>
  
  <p>I have this request that work but take too much time to load... I would like to have an optimize version to group by payment_id and take the last status.</p>
  
  <pre><code>SELECT pstatus.*
  FROM `payment_status` AS pstatus
  WHERE pstatus.id = (
     SELECT id
     FROM `payment_status`
     WHERE pstatus.status = '200'
     ORDER BY created DESC
     LIMIT 1
  )
  GROUP BY pstatus.payment_id
  ORDER BY pstatus.payment_id DESC
  </code></pre>