Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2011-05-18 : 03:20:14
|
| I have one table ENCOUNTER_PARTYHAVING lots of columns but I am concern with only two columns.ENCOUNTER_KEY, PARTY_ROLE_TYPE_KEY( ENCOUNTER_KEY, PARTY_ROLE_TYPE_KEY ) is primary key for the tableWhat i want, I want to select only those ENCOUNTER_KEY which are having both the PARTY_ROLE_TYPE_KEY is 16 and 18.Please help me out how can I do that.Vaibhav TIf I cant go back, I want to go fast... |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2011-05-18 : 03:37:37
|
I got the solution but can any one tell me that Is there any other solution possible ?SELECT * FROM (SELECT ENCOUNTER_KEY FROM ENCOUNTER_PARTY WHERE PARTY_ROLE_TYPE_KEY = 16 ) AINNER JOIN (SELECT ENCOUNTER_KEY FROM ENCOUNTER_PARTY WHERE PARTY_ROLE_TYPE_KEY = 18) BON A.ENCOUNTER_KEY = B.ENCOUNTER_KEY Vaibhav TIf I cant go back, I want to go fast... |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-05-18 : 03:38:43
|
select ENCOUNTER_KEY from ENCOUNTER_PARTY epwhere PARTY_ROLE_TYPE_KEY = 16and exists(select * from ENCOUNTER_PARTY ep2 where ep2.ENCOUNTER_KEY = ep.ENCOUNTER_KEY and ep2.PARTY_ROLE_TYPE_KEY = 18) No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2011-05-18 : 03:43:36
|
| ah...! Thanks webfred...Vaibhav TIf I cant go back, I want to go fast... |
 |
|
|
|
|
|