June 3, 2011 at 3:32 pm
I feel that I have a pretty unique problem on my hands.
Here is an example of the table I have:
AdvisorId LocationID
12 260
12 320
111 120
203 347
40 260
35 260
13 320
I have the parameter @AdvisorID I am getting from reporting services. I need to get the other AdvisorID's where the Location is the same as the @AdvisorID parameter. So if I have AdvisorID 12 I am passing then I want to get AdvisorIDs where LocationID is 260 and 320. Is there a way to do this?
June 4, 2011 at 10:26 pm
This is pretty standard stuff actually. Here's one way to code it.
If your table is large you would certainly benefit from having indexes on both LocationID and AdvisorID.
select distinct AdvisorID
from YourTable
where LocationID in
(select locationID
from YourTable
where AdvisorID = @AdvisorID
)
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
June 6, 2011 at 7:29 am
Thanks for your help! I keep forgetting about the IN statement.
You saved me a lot of aggravation and time.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply