title: Saving a COUNT column appearance while printing each row in the table
body: <p>So there is a question I have not been able to find an answer to. Say you want to print each row in a table like the following:</p>
  
  <pre><code>ID  | Name | Location
  ----+------+----------
  1   | Adam | New York
  2   | Eva  | London
  3   | Jon  | New York
  </code></pre>
  
  <p>which would give the result</p>
  
  <pre><code>1 Adam New York  
  2 Eva London  
  3 Jon New York
  </code></pre>
  
  <p>Say that I at the same time would like to count the number of occurrences someone lives in a specific city, and save that value for printing after I've iterated through the table; is that possible? For example, printing the following:</p>
  
  <pre><code>1 Adam New York  
  2 Eva London  
  3 Jon New York  
  Inhabitants in New York: 2  
  Inhabitants in London: 1
  </code></pre>
  
  <p>Is this possible or would you have to iterate through the entire table twice by grouping by <code>Location</code> the second time, and counting those?</p>
  
  <p>EDIT:
  To clarify, I know I can solve it by calling:</p>
  
  <pre><code>SELECT * FROM table; 
  SELECT CONCAT('Inhabitants in ', Location, ': ', COUNT(ID))
  FROM table
  GROUP BY Location;
  </code></pre>
  
  <p>But now I am iterating through it twice. Is it possible to do it in only one iteration?</p>