Oracle除法问题
我有这个查询:
select (round(scp.qty/ppc.qty) * 100,4) || '%' as qtyco from .....
问题是,它不是返回“0.123%”,而是只返回“.123%”
任何想法为什么......或者我该如何解决这个问题? 两个 qty 列的类型是 NUMBER(12,0)
谢谢!
I have this query :
select (round(scp.qty/ppc.qty) * 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这只是一个显示问题:由于您使用的是
||
连接运算符,因此您的数字会转换为 varchar(Oracle 会隐式执行转换)。您应该明确询问格式,例如: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:Oracle 可以自动将数字转换为字符。我认为手动转换会更好,这样你就可以控制如何做。
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.