开发者

Oracle division problem

开发者 https://www.devze.com 2023-02-07 11:19 出处:网络
I have this query : select (round(scp.qty/ppc.q开发者_如何学JAVAty) * 100,4) || \'%\' as qtyco from .....

I have this query :

select (round(scp.qty/ppc.q开发者_如何学JAVAty) * 100,4) || '%' as qtyco from .....

The problem is that instead of returning "0.123 %" it returns just ".123 %"

Any ideea why..or how could i fix this? the types of the two qty columns are NUMBER(12,0)

Thanks!


this is just a display issue: your number is converted to a varchar since you're using the || concatenation operator (Oracle performs the conversion implicitely). You should ask for a format explicitely, for example:

select to_char(round(scp.qty / ppc.qty * 100, 4), 'fm990.9999') || '%' as qtyco


Oracle can convert the number to char automatically. I think it would be better to convert it manually, so you would have control how to do it.

0

精彩评论

暂无评论...
验证码 换一张
取 消