exclusive query

juster21

Well-known Member
Joined
Jun 3, 2005
Messages
867
I have a table which contains data about what locations a business is in....geographic locations. I need a query to pick out the people with listings in only 1 geographic location. The people are identified by a customer #.
The locations have a location #.

Ex.
Person___Loc
Me_______1
Me_______2
Me_______3
You______3
Us_______1
Us_______3

Result = You 3


If possible, I would like to specify which location also.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
In the SQL string below, change "MyTable" and "Loc" to whatever table name and field name you need them to be. Go into Query Designer and switch to "SQL View", then paste the SQL in. Switch to "Datasheet View" to see the results and "Design View" to see the query graphically represented.

Code:
SELECT [MyTable].Person, Count([MyTable].Loc) AS Count_Of_Loc
FROM [MyTable]
GROUP BY [MyTable].Person
HAVING (((Count([MyTable].Loc))=1));
 
Upvote 0

Forum statistics

Threads
1,214,848
Messages
6,121,917
Members
449,055
Latest member
KB13

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top