observe the following line used in a select statement
(case when p1 = 0 then 1 else (p2-p1)/p1 end) as delta_pct,
this line gives the percentage change between p1 and p2, and if p1 is 0 it returns 1 to avoid the divide by 0 error. but it gives 1 if p2 is also 0 which is incorrect. how do I modify his line to account for that case as well?
something like
case when p1 = 0
case when p2 = 0
then 0
then 1
else (p2-p1)/p1