title: How to retrieve the highest value on same data ID
body: <p>For my monitoring tool (Centreon), I need to create a script that will send me every day a report with my hosts / services that have been acknowledged for X days.</p>
  <p>For this I need to get information in several tables which I can do with the following query</p>
  <pre><code>SELECT DISTINCT     services.host_id,
                          hosts.name,
                          services.service_id,
                          services.description,
                          comments.author,
                          comments.DATA,from_unixtime(comments.entry_time), 
                          comments.comment_id
  FROM  services,
          hosts,
          comments 
  WHERE services.host_id=hosts.host_id 
          AND hosts.host_id=comments.host_id 
          AND services.acknowledged='1' 
          AND services.enabled='1' 
          AND comments.DATA NOT LIKE '%downtime%'
  </code></pre>
  <p><a href="https://i.stack.imgur.com/4P8pw.png" rel="nofollow noreferrer">MySQL query Result</a></p>
  <p>What I'll need is to have as result only the highest comment_id per service_id</p>
  <p>Is there a way to do this directly in a query or do I have to import my entire result into my python script and process the data afterwards?</p>
  <p>Thanks in advance for your help.</p>