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 2005 Forums
 Transact-SQL (2005)
 Trouble with Count()

Author  Topic 

haoest
Starting Member

8 Posts

Posted - 2008-08-13 : 14:24:24
Hi, I want a query that gets a list of city/state/zipcode triplets, along with the number of cities that are associated with each zip code. What's the best way to do this?

This is what I have so far. I can either take the count, or the zipcode out.


select zipcode, statename, count(cityname) cnt
from xzip_state_mapping
group by zipcode, statename


Is there anyways I can stick zip code in there and have CNT reflect the correct number of cities a zip code maps to?

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2008-08-14 : 02:53:42
count(distinct cityname)

Em
Go to Top of Page
   

- Advertisement -