字符串加倍或小数
问题描述:
如何将字符串转换为双精度或小数?在Exact Online(REST API)中,我尝试使用字符串字段中的十进制值进行计算。例如items.netprice + items.notes
。字段items.notes
包含十进制值。 试用cast
和convert
结合float
和decimal
。字符串加倍或小数
答
我会用类似的解决方案:
select case
when regexp_replace(c, '[^0-9.]', '', 1, 0, 'g') = c
then to_number(c)
else null
end
from (select '123.45' c
from [email protected]
union all
select '123invalid.45' c
from [email protected]
)
的case
有regexp_replace
确保非数量为空返回。如果认为有必要,您可能需要将其更改为错误。
目前尚不清楚你在做什么。你能证明你给的东西到目前为止吗? –