<p>SQL Experts,</p>

<p>Is there an efficient way to group runs of data together using SQL?<br>
Or is it going to be more efficient to process the data in code.  </p>

<p>For example if I have the following data:</p>

<pre><code>ID|Name
01|Harry Johns
02|Adam Taylor
03|John Smith
04|John Smith
05|Bill Manning
06|John Smith
</code></pre>

<p>I need to display this:</p>

<pre><code>Harry Johns
Adam Taylor
John Smith (2)
Bill Manning
John Smith
</code></pre>

<p>@Matt: Sorry I had trouble formatting the data using an embedded html table it worked in the preview but not in the final display.</p>

For this particular case, all you need to do is group by the name and ask for the count, like this:
```
```
select Name, count(*)
from MyTable
group by Name
```
```
That'll get you the count for each name as a second column.
You can get it all as one column by concatenating like this:
```
```
select Name + ' (' + cast(count(*) as varchar) + ')'
from MyTable
group by Name
```
```