title: group by behavior
body: <p>I need to find the rows with the greatest value in their group.</p>
  
  <p>I did a lot of research and I found plenty of solutions: join, temporary table, etc.</p>
  
  <p>Still I wanted to try something with "order by ... having ..." and I found something weird.</p>
  
  <p>This is my query:</p>
  
  <pre><code>SELECT MAX(id) AS MaxValue, MyTable.* 
  FROM MyTable
  GROUP BY name
  HAVING id = MaxValue
  </code></pre>
  
  <p>I get a list of rows as result but I don't have a row for every name.</p>
  
  <p>I obtain many rows when I do this:</p>
  
  <pre><code>SELECT * FROM MyTable WHERE name = 'John'
  </code></pre>
  
  <p>But the result of the first query doesn't contain any row with the name 'John' and I don't get anything if I do this:</p>
  
  <pre><code>SELECT MAX(id) AS MaxValue, MyTable.* 
  FROM MyTable
  GROUP BY name
  HAVING id = MaxValue AND name = 'John'
  </code></pre>
  
  <p>I don't really understand how it works and it triggers me.</p>
  
  <p>Could anyone explain me this behavior? </p>
  
  <p>I did't ask "how to do that". I just didn't understand how "group by ... having" works.</p>