<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>

Counting the number of times tags are used might be a google example:
```
```
SELECT TagName, Count(*)
AS TimesUsed
FROM Tags
GROUP BY TagName ORDER TimesUsed
```
```
If you simply want a distinct value of tags, I would prefer to use the
```
DISTINCT
```
statement.
```
```
SELECT DISTINCT TagName
FROM Tags
ORDER BY TagName ASC
```
```