title: SQL to select highest row of a combination of two columns
body: <p>I need help with a query for MySQL 5.5</p>
  
  <p>I'm trying to only select 1 line per combination of 2 columns (tan, location_id) after sorting the rows by location_id, count_number, try_number. So basically I want to have a query that returns only the yellow rows from the following picture. Only the 1 record per combination of tan/location_id with the highest "count_number" und "try_number" within that group.</p>
  
  <p><a href="https://i.stack.imgur.com/5wZPf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5wZPf.png" alt="enter image description here"></a></p>
  
  <p>This is the query that I currently have.</p>
  
  <pre><code>select tan, quantity, count_number, try_number, location_id 
  from inventario_inventoryregistry
  where tan = '53-100554-01'
  order by location_id desc, count_number desc, try_number desc;
  </code></pre>