求教To_number转化问题

瞌觉兴国 2015-08-27 01:38:47
原句
select x.exp_report_header_id 头ID,
x.exp_report_line_id 行ID,
x.report_amount 总金额,
y.expense_object_desc 税码,
to_number(h.description,'9999') 总金额X税码
from exp_report_lines x,
exp_report_objects y,
EXP_REPORT_OBJECTS z,
exp_expense_object_types_vl h
where x.exp_report_line_id = y.exp_report_line_id
and x.exp_report_line_id = z.exp_report_line_id
and h.expense_object_type_id = z.expense_object_type_id
and h.expense_object_type_code = 'TAX_CODE'
and x.exp_report_header_id = 179840

句子的意思是查出税额是多少(即总金额×税码) 税码是 varchar类型的 值为 6%
我想把它转化成 number类型好做运算。但是 TO_NUMBER 怎么写都不对,一直报无效数字。 求教这里该怎么写
...全文
164 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
pobaby 2015-08-30
  • 打赏
  • 举报
回复
很明显是有空值或者字符,看看数据吧,或者用正则
bw555 2015-08-29
  • 打赏
  • 举报
回复
应该还是数据的事,试试使用正则表达式检索不符合数字正则表达式的数据吧
「已注销」 2015-08-29
  • 打赏
  • 举报
回复
数据中可能有非空非数值的值。
mayanzs 2015-08-27
  • 打赏
  • 举报
回复
x.report_amount * replace(y.expense_object_desc,'%')*0.01
mayanzs 2015-08-27
  • 打赏
  • 举报
回复
那就再*0.01就行了
瞌觉兴国 2015-08-27
  • 打赏
  • 举报
回复
引用 1 楼 mayanzs 的回复:
先把%去掉: x.report_amount * replace(y.expense_object_desc,'%')
算出来的数不对啊, 6%是 0.06,这个直接按6算了
mayanzs 2015-08-27
  • 打赏
  • 举报
回复
先把%去掉: x.report_amount * replace(y.expense_object_desc,'%')

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧