it's almost done except i use function to get the accumulative value of downline members. i'm not sure if it's allowed.
judges r picky, they don't like temp table nor table variable, i assume they'd rule out function too.
anyway, it's very good challenge for your tsql. i just found it out last night and i love it immediately.
enjoy~~