oracle中写环比sql时候分母为0的情况
当编写环比sql的时候,环比=(本月-上月)/上月 若上月的数据量为0,这时sql会报错 “divisor is equal to zero”处理方法为:decode(分母,0,1,分母) 这样就可以解决这个问题了,或者用case when;另:截取小数点后位数的函数trunc(字段,2)比如 :select trunc(19.812,2) from dual; ---> 1...
原创
2010-11-29 16:30:07 ·
2915 阅读 ·
0 评论