title: Latest datetime from unique mysql index
body: <p>I have a table. It has a pk of id and an index of [service, check, datetime].</p>
  
  <pre><code>id  service  check   datetime  score
  ---|-------|-------|----------|-----
  1  | 1     |  4    |4/03/2009 | 399
  2  | 2     |  4    |4/03/2009 | 522
  3  | 1     |  5    |4/03/2009 | 244
  4  | 2     |  5    |4/03/2009 | 555
  5  | 1     |  4    |4/04/2009 | 111
  6  | 2     |  4    |4/04/2009 | 322
  7  | 1     |  5    |4/05/2009 | 455
  8  | 2     |  5    |4/05/2009 | 675
  </code></pre>
  
  <p>Given a service 2 I need to select the rows for each unique check where it has the max date. So my result would look like this table.</p>
  
  <pre><code>id  service  check   datetime  score
  ---|-------|-------|----------|-----
  6  | 2     |  4    |4/04/2009 | 322
  8  | 2     |  5    |4/05/2009 | 675
  </code></pre>
  
  <p>Is there a short query for this? The best I have is this, but it returns too many checks. I just need the unique checks at it's latest datetime.</p>
  
  <pre><code>SELECT * FROM table where service=?;
  </code></pre>