Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Query Help

Author  Topic 

sulman
Starting Member

20 Posts

Posted - 2007-02-20 : 10:03:44
Hi,

I have a table that has the following:
col1
--
A
A
A
B
C
C

I need to be able to count how many of each there are. i.e. I need a query that would return the following data:
col1 count
---- -----
A 3
B 1
C 2

Is this possible?

Many thanks

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-20 : 10:05:16
select col1, count(*) as count
from table1
group by col1
order by col1


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

sulman
Starting Member

20 Posts

Posted - 2007-02-20 : 10:19:43
Excellent! works a treat.

Thanks so much.
Go to Top of Page
   

- Advertisement -