Need help with query for previous year spend vs. current year

Need help with query for previous year spend vs. current year

Post by SmVmZiBTdH » Sun, 09 Sep 2007 05:40:01


Thanks!
--
Thanks,

Jeff





> > my reports. So, in the sp, I build two temp tables one for previous year >>>> and one for current year. How do I bash these tables together in order to >>>> get a previous year $$ column and a current year $$ column by account number >>>> and branch location? I think I have part of the answer join the two temp > > > tables on account number and branch location and select all columns giving an > > > alias to one of the $$ columns for either previous or current year. The > > > sticky part is, there may be account numbers in current year that don exist > > > in previous year and vice versa. I like to put $0.00 in this case where > > > there was no spend. I tried a full outer join, but I get way too many > > > records and a lot of duplicate values. Has anyone ever faced this problem > > > and do you have a solution? I like to avoid using cursors if possible > > > because they seem to degrade performance.> > > -- > > > Thanks,> > > > > > Jeff