Try changing
case
when (r1.rate+r2.rate) = 0 then 0
else round(((r1.rate-r2.rate)/(r1.rate+r2.rate))*100.0,2)
end as perc
to
isnull(round(((r1.rate-r2.rate)/(nullif(r1.rate+r2.rate,0)))*100.0,2),0) as perc
____________________________________________________
Deja View - The strange feeling that somewhere, sometime you've optimised this query before
How to get the best help on a forum
http://www.sqlservercentral.com/articles/Best+Practices/61537