February 9, 2011 at 11:08 am
Dear all
i have a table with following structure
clientcode parentcode groupid
-------------- ---------- -----------
FIB064 P1 1
FIB064 P1 3
FIB064 P2 2
FIB064 P5 2
FIB064 P5 3
FIB065 P2 2
FIB065 P4 1
FIB065 P6 4
FIB066 P6 4
FIB066 P5 2
FIB066 P5 3
i want to find the common groupid among the clientcodes
ie in the above case group id 2 is common for FIB064,FIB065 and FIB066
can anyone help please..
February 9, 2011 at 11:27 am
Hey Denny, welcome to SSC. Since you're new here, you'll probably want to take a look at the first link in my signature. It describes how to setup data/ddl so we can help you easier by creating consumable test structures.
So, until you do that, some ideas to get you on your way.
First, how are you passing in the FIB codes? Are you telling it those three codes, or are you looking to do it for everything in the table?
If you're telling it those three codes, what you can do is look for any groupID with a count of 3 (or more) across the group ID using a where clause for the FIB codes.
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
February 10, 2011 at 12:03 am
finally i got the solution
select groupid from #temp group by groupid
Having Count(distinct clientcode) =
(
Select count(*) from
(select distinct clientcode from #temp) X
)
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply