title: T-SQL SELECT with GROUP BY id
body: <p>I have table with '<strong>People</strong>'</p>
  
  <p>Columns</p>
  
  <ul>
  <li>ID</li>
  <li>Name</li>
  <li>Age</li>
  </ul>
  
  <p>And table with '<strong>Notes</strong>':</p>
  
  <p>Columns</p>
  
  <ul>
  <li>ID</li>
  <li>Text</li>
  <li>FK_Author</li>
  </ul>
  
  <p>I want to select count of notes for all authors from people table and their name and age, but I want to group it by PERSON ID, not name. There are many situations when people have same name, but ID is obviously always different.</p>
  
  <p>EXAMPLE (input)</p>
  
  <p><strong>PEOPLE:</strong></p>
  
  <pre><code>╔════╦═══════╦═════╗
  ║ ID ║ NAME  ║ AGE ║
  ╠════╬═══════╬═════╣
  ║  1 ║ John  ║  12 ║
  ║  2 ║ Annie ║  29 ║
  ║  3 ║ John  ║  44 ║
  ╚════╩═══════╩═════╝
  </code></pre>
  
  <p><strong>NOTES:</strong></p>
  
  <pre><code>╔════╦═══════╦═══════════╗
  ║ ID ║ TEXT  ║ FK_AUTHOR ║
  ╠════╬═══════╬═══════════╣
  ║  1 ║ 'aaa' ║         1 ║
  ║  2 ║ 'aaa' ║         1 ║
  ║  3 ║ 'aaa' ║         2 ║
  ║  4 ║ 'aaa' ║         2 ║
  ║  5 ║ 'aaa' ║         3 ║
  ╚════╩═══════╩═══════════╝
  </code></pre>
  
  <p><strong>Expected result:</strong></p>
  
  <pre><code>╔═══════╦═════╦════════════╗
  ║ NAME  ║ AGE ║ TOTALCOUNT ║
  ╠═══════╬═════╬════════════╣
  ║ John  ║  12 ║          2 ║
  ║ Annie ║  29 ║          2 ║
  ║ John  ║  44 ║          1 ║
  ╚═══════╩═════╩════════════╝
  </code></pre>
  
  <p>When I select data I have to group by Name too if I want to select this column because if I dont, I get error.</p>