I reduced it down to the following and got the correct number of records the original SP returned bu the sums were all wrong. I didn't filter on UserID.
I think I understand that. I was able to build the derived output but still had the problem with master table. IS it possible to keep this result in memory...