在Oracle SQL中乘以列值
我有以下查询:
SELECT RTRIM(TO_CHAR('dst.' || per_growth,
'FM9G999G999G999G999G990D99999999999',
' NLS_NUMERIC_CHARACTERS = '',.'' '),
',')
FROM dst__d_data dst;
我已经串联 per_growth 列标记, dst。
现在,我想要的是 'dst。 || per_growth * 0.01
。但是,这是上升错误消息:
ORA-01722 :无效号码
在这种情况下如何执行乘法?
I have following query:
SELECT RTRIM(TO_CHAR('dst.' || per_growth,
'FM9G999G999G999G999G990D99999999999',
' NLS_NUMERIC_CHARACTERS = '',.'' '),
',')
FROM dst__d_data dst;
I have concatenated per_growth column label with the dst.
Now, what I want is 'dst.' || per_growth * 0.01
. However, it is rising error message:
ORA-01722: invalid number
How can I carry out multiplication in this scenario?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您现有的查询将引起相同的错误。您不能首先连接,然后将
应用于_char
;to_char
期望一个数字,而不是字符串。首先将数字转换为字符串,然后将condenate'dst。'
转换为to_char
的结果。修复第一个错误(即使对于现有查询)后,参数中的0.01乘以
to_char
不应导致任何新问题。Your existing query will raise the same error. You can't concatenate first, and then apply
TO_CHAR
;TO_CHAR
expects a number, not a string. First convert the number to string, and then concatenate'dst.'
to the result ofTO_CHAR
.After you fix this first mistake (even for your existing query), multiplying by 0.01 in the argument to
TO_CHAR
should not cause any kind of new problem.您可以使用
在完成使用
'',。''''
模式的数值转换后,前缀一些字符串的内容(因为数据似乎具有逗号作为十进制的分离器)和乘法操作< kbd>
You can use
prefix some string stuff after finishing the numerical conversion with
'',.''
pattern(as the data seems to have comma as decimal seperator) and multiplication operationDemo