oracle to_namber以後報ora-01722:無效數字

寫的sql:
sql

select ide

 to_number(substr(B.年齡, 1, instr(B.年齡, '天') - 1)) as 年齡, A.病人id, A.主頁idspa

  from 病案主頁 A, 病人信息 Borm

 where A.病人ID = B.病人IDblog

   and A.主頁ID = B.主頁IDget

   and to_number(substr(B.年齡, 1, instr(B.年齡, '天') - 1)) < 29it

   and B.年齡 not like '%歲%'io

   and B.年齡 not like '%月%'class

報錯:select

wKiom1i28uDwdQCpAAAeCsmdhg0512.png-wh_50

加上強制規則,運行經過:

select /*+rule*/

 to_number(substr(B.年齡, 1, instr(B.年齡, '天') - 1)) as 年齡, A.病人id, A.主頁id

  from 病案主頁 A, 病人信息 B

 where A.病人ID = B.病人ID

   and A.主頁ID = B.主頁ID

   and to_number(substr(B.年齡, 1, instr(B.年齡, '天') - 1)) < 29

   and B.年齡 not like '%歲%'

   and B.年齡 not like '%月%'


注意:

and to_number(substr(B.年齡, 1, instr(B.年齡, '天') - 1)) < 29

不能放在最後一個條件,不然也會報錯!

相關文章
相關標籤/搜索