0

Hi Guys,

This is my problem:

In the below table:


donor receptor
1 -> 4
2 -> 5
4 -> 6

The above reads as follows...

Student 1 donates all of his/her money to Student 4
Student 2 donates all of his/her money to Student 5
Student 4 donates all of his/her money to Student 6

I would like to pull all of the ultimate donors from the above table. An ultimate donor is someone who is at all times a receptor and never a donor.

So in the above scenario Students 5 and 6 are ultimate donors. Does anyone have any ideas on how this can be accomplished?

I will be very appreciative of any inputs.

Thanks

2
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by tesuji
0

Hello bajanstar

you may try this statement:

select receptor as 
  'ultimate donors, really? Shouldn''t it be ultimate receptors?' 
      from inthebelowtable where receptor NOT IN 
          (select donor from inthebelowtable)

krs,
tesu

0

hi tesu,
You are correct. It is suppose to be ultimate receptor. Thanks for you input.

so what do you think about this solution

select distinct receptor
from yourtable a
left join (select donor from yourtable) b on a.receptor = b.donor
where b.donor is null
0

no, not that a good idea, consider:

left join (there are no null entries, because each left value has its mate in right column)
1 4
2 5
4 6

right join (if right value has no mate in left column, null will be inserted left hand side)
1 4
null 5
null 6

possibly, select looks like:
select b.donor, b.receptor from inthebelowtable a right join inthebelowtable b
on a.receptor = b.receptor where a.donor IS NOT null

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.