加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

关于oracle的数据库的数据Long和Number的转化字段

发布时间:2020-12-12 16:05:53 所属栏目:百科 来源:网络整理
导读:在数据处理的过程中发现,有需要A 表的 id(Number) 和B表的source_code(Char)类型的关联数据; 后来发现 有类似 20150619120238-145 这种格式的source_code也不是科学记数法的数据; select a.id, nvl(tem.cancel_amount,0.00) as am from a left join (se

在数据处理的过程中发现,有需要A 表的 id(Number) 和B表的source_code(Char)类型的关联数据;


后来发现 有类似 20150619120238-145 这种格式的source_code也不是科学记数法的数据;


select a.id,
nvl(tem.cancel_amount,0.00) as am
from a
left join (select a1.source_code,b.cancel_amount,b.cancel_date
from (select det.id,det.source_code
from det
where source_type = 6
and return_type = 3) a1
inner join (select relative_id as relative_id,
sum(cancel_amount) as cancel_amount,
max(create_date) as cancel_date
from detail
where source_order_type = 2
group by relative_id) b on a1.id = b.relative_id) tem on to_char(a.id) =
tem.source_code
where 1 = 1
and a.TOTAL_DATE >= to_date('2016-05','yyyy-mm')
and a.TOTAL_DATE <= to_date('2016-08','yyyy-mm')
order by a.TOTAL_DATE,a.id


单独查询tem和 a都是正确的 。错误就在关联处没有加上 to_char;总是报告“无效数字“的错误;


经过同事讨论发现:

select to_number(20150619120238-145) from dual; -------------oracle数据库会自动做减法; 运行没问题 当做了一个表达式 减法运算;

select to_number(‘’20150619120238-145‘’) from dual;---------------单引号的字符串强制类型转换,报错 :无效数字;


oracle就是有这么多规矩 ,还需要学习的东西有很多……

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读