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!

SQL Question

Status
Not open for further replies.

qlan

MIS
Feb 10, 2005
84
US
Hi,
I have a table named Customers. In this table, there is a column named SalesReps and each SalesRep has many different Customers. Would you please help me to write a query to select each SalesRep with only one Customer. For example, SalesRep A has 5 Customers and SalesRep B has 4. I only want to show one Customer for each SalesRep. Thanks so much for your help.
 
SELECT SalesRep, Min(Customer) As AnyCustomer
FROM Customers
GROUP BY SalesRep;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Which customer do you want to show?

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Are you looking for only 1 customer per sales rep, regardless of how many customers each rep has? Or <i>only</i> those sales reps who have just 1 customer?
 
if all that you need is the sales rep name then
SELECT SalesRep
FROM Customers
GROUP BY SalesRep
having count(*)=1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top