title: How do I use T-SQL Group By
body: <p>I know I need to have (although I don't know why) a <code>GROUP BY</code> clause on the end of a SQL query that uses any aggregate functions like <code>count</code>, <code>sum</code>, <code>avg</code>, etc:</p>
  
  <pre><code>SELECT count(userID), userName
  FROM users
  GROUP BY userName
  </code></pre>
  
  <p>When else would <code>GROUP BY</code> be useful, and what are the performance ramifications?</p>