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.
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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.