sql中的OraInvalidNumberError

sql中的OraInvalidNumberError,sql,Sql,我有下面的代码,我试图获取所有值的总和。但我得到了无效的数字错误 select sum ( DECODE ( a.billed_uom, 'kW', DECODE ( a.multiplier, 'N/A', 0, ' ', 0,

我有下面的代码,我试图获取所有值的总和。但我得到了无效的数字错误

select 
     sum (
           DECODE (
              a.billed_uom,
              'kW', DECODE (
                       a.multiplier,
                       'N/A', 0,
                       ' ', 0,
                       DECODE (a.billed_usage, ' ', 0, a.billed_usage)),
              'kVA', DECODE (
                        a.multiplier,
                        'N/A', 0,
                        ' ', 0,
                        DECODE (a.billed_usage, ' ', 0, a.billed_usage)),
              0))
           AS billed_kw_kva    

             FROM zbi_s_metrdetail a WHERE billing_doc <> ' ' ;

修正数据!查找不正确的值:

select billed_usage
from zbi_s_metrdetail
where not regexp_like(billed_usage, '^[0-9]+[.]?[0-9]*$')


当发现错误值时,请修复它们

正确的格式使SQL更易于阅读。也来看看。顺便说一句,您使用的是哪种dbms?当StackOverflow不允许您将问题命名为“ORA Invalid Number Error in SQL”时,其背后的原因是这已经被询问和回答了很多次+这并不能真正描述您的问题。删除标题中的空格不是一个好办法……我不确定,但是你的结果应该是varchar,对吗?因此,当您编写
DECODE(a.billed_用法,,,0,a.billed_用法)
时,
0
应该是
'0'
@Nebi-我试过了,但没有幸运的是,您在所有的0中都这么做了?否则试着不要做全部的事情,而是为自己解码。从内心深处开始。
select billed_usage
from zbi_s_metrdetail
where not regexp_like(billed_usage, '^[0-9]+[.]?[0-9]*$')
select multipler
from zbi_s_metrdetail
where not regexp_like(multipler, '^[0-9]+[.]?[0-9]*$')