Hi there. I'm having a hard time figuring out how to write this query and was wondering if anyone here could help. Have a look at the table (very simplified) attached. What I need is a query with three parameters:
Here's the hard part:
Using these variables, I need to return an integer representing the difference (in days) between @ScheduleDate and the date that @ParticipantA and @ParticipantB were last assigned to the same Team. If they have never been assigned to the same team, the query should return 0.
Any questions? Please let me know. Thank you very much in advance for any help you can offer.
P.S. By the way, I am aware that - in the sample data - none of the participants have every been assigned to the same team. I was trying to keep the data as simple as possible. In this case, the query I'm looking for would return zero for every pair of participants submitted to it.