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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Statment ??!!

Status
Not open for further replies.

amal2004

Technical User
Jul 2, 2004
20
US
I have a table that has an [order id] column and a [rep id] column. An order could have two reps or more associated with. I would like a have a query that will bring me all the orders that have more than one rep associated with.

Thanks
 
Something like this ?
SELECT A.* FROM yourTable A INNER JOIN
(SELECT [order id], Count(*) FROM yourTable GROUP BY [order id] HAVING Count(*)>1) B
ON A.[order id]=B.[order id]
;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Something like this ?
SELECT A.* FROM yourTable A INNER JOIN
(SELECT [order id], Count(*) FROM yourTable GROUP BY [order id] HAVING Count(*)>1) B
ON A.[order id]=B.[order id]
;

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