我的PL / SQL过程中有2个变量来获取计数。 使用这些值我计算两个表之间的百分比变化。我就是这样做的:
SELECT (
decode(original_count,
0,
to_number(0),
((todays_count - original_count)/original_count)
)
)
INTO percentage_change
FROM DUAL;
我想知道是否有办法通过:=
分配来实现
类似的东西:
percentage_change := (decode(original_count,
0,
to_number(0),
((todays_count - original_count)/original_count)
)
)
我可以这样做吗?
答案 0 :(得分:1)
您可以使用案例构造:
percentage_change := case when original_count=0 then 0
else (todays_count - original_count)/original_count end;