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 |
|
velvettiger
Posting Yak Master
115 Posts |
Posted - 2008-07-09 : 17:56:25
|
Hi,ProblemIn the below table:donor receptor 1 -> 42 -> 54 -> 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 5Student 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 |
|
|
singularity
Posting Yak Master
153 Posts |
Posted - 2008-07-09 : 19:13:43
|
| select distinct receptorfrom yourtable aleft join (select donor from yourtable) b on a.receptor = b.donorwhere b.donor is null |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-10 : 01:07:15
|
| select distinct receptorfrom yourtable where receptor not in (select donor from yourtable) |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-07-10 : 01:11:14
|
quote: An ultimate donor is someone who is at all times a receptor and never a donor
 KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
velvettiger
Posting Yak Master
115 Posts |
Posted - 2008-07-10 : 07:09:29
|
| Oh an ultimate recpetor is someone who is at all time a receptor and never a donorMy bad... |
 |
|
|
|
|
|