Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Names with Multiple Locations

Status
Not open for further replies.

netrusher

Technical User
Feb 13, 2005
952
US
I have a table with two fields.

1. Name
2. Location

Each name will have at least one location. Some names will have multiple locations (2-4).
What I want to accomplish is to find out how many distinct names I have and also to get
a count of how many names that have multiple locations. Ideally I would like to see each Name
with each location under it as well as have the count of distinct names and the count of
names with multiple locations.

Any thoughts and or suggestions?
 
the count of distinct names
SELECT Count(*) AS NumOfDictinctNames FROM (
SELECT DISTINCT [Name] FROM yourTable
) AS D
the count of names with multiple locations
SELECT Count(*) AS NumOfMultipleLoc FROM (
SELECT [Name] FROM yourTable GROUP BY [Name] HAVING Count(*) > 1
) AS M

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top