所有的日期字段都為字符串報(bào)錯(cuò)為expected char got number從報(bào)錯(cuò)分析來看是類型不一樣,也就是*100不是數(shù)字值,但是第二段代碼卻過了,這就很不理解了,如果真的類型不一樣第二段*100也會報(bào)錯(cuò)才對下面的這兩處為什么會有沖突select case ? when sysdate < to_date(cih.begin_year || '-' || cih.begin_month || '-01', 'yyyy-MM-dd') ? then '0.0' ? when cih2.time2<sysdate? then '100'? when ??????? cih2.time2-to_date(cih.begin_year || '-' || cih.begin_month || '-01', 'yyyy-MM-dd')=0? then '0.0'????--這里?
else (((to_date(cih.begin_year || '-' || cih.begin_month || '-01',
'yyyy-MM-dd')-sysdate)+1)/(cih2.time2-to_date(cih.begin_year || '-' ||
cih.begin_month || '-01', 'yyyy-MM-dd'))*100)??? --這里,報(bào)錯(cuò)的地方這個(gè)100下面有下劃線end 項(xiàng)目總體進(jìn)度 ?from cbm_item_headers cih,(select a.*,(case ??????? when To_number(a.end_month, '99') < 12 ??????? then to_date(a.end_year || '-' || to_char(cih2.end_month2,'99') || '-01', 'yyyy-MM-dd') ??????? else to_date(to_char(cih2.end_year2,'9999') || '-' || '01' || '-01', 'yyyy-MM-dd') end) time2from cbm_item_headers a,(select
item_code,to_number(end_year, '9999') + 1
end_year2,to_number(end_month, '99')+1 end_month2 from cbm_item_headers)
cih2 where a.item_code=cih2.item_code) cih2where cih.item_code=cih2.item_code我去掉這兩處其中一處就可以運(yùn)行select(((to_date(cih.begin_year
|| '-' || cih.begin_month || '-01',
'yyyy-MM-dd')-sysdate)+1)/(cih2.time2-to_date(cih.begin_year || '-' ||
cih.begin_month || '-01', 'yyyy-MM-dd'))*100)????--去掉了case就可以運(yùn)行from cbm_item_headers cih,(select a.*,(case ??????? when To_number(a.end_month, '99') < 12 ??????? then to_date(a.end_year || '-' || to_char(cih2.end_month2,'99') || '-01', 'yyyy-MM-dd') ??????? else to_date(to_char(cih2.end_year2,'9999') || '-' || '01' || '-01', 'yyyy-MM-dd') end) time2from cbm_item_headers a,(select
item_code,to_number(end_year, '9999') + 1
end_year2,to_number(end_month, '99')+1 end_month2 from cbm_item_headers)
cih2 where a.item_code=cih2.item_code) cih2where cih.item_code=cih2.item_code----------------------------------------------------------select case ? when sysdate < to_date(cih.begin_year || '-' || cih.begin_month || '-01', 'yyyy-MM-dd') ? then '0.0' ? when cih2.time2<sysdate? then '100'? when ??????? cih2.time2-to_date(cih.begin_year || '-' || cih.begin_month || '-01', 'yyyy-MM-dd')=0? then '0.0'????????--去掉了else就可以運(yùn)行end 項(xiàng)目總體進(jìn)度 ?from cbm_item_headers cih,(select a.*,(case ??????? when To_number(a.end_month, '99') < 12 ??????? then to_date(a.end_year || '-' || to_char(cih2.end_month2,'99') || '-01', 'yyyy-MM-dd') ??????? else to_date(to_char(cih2.end_year2,'9999') || '-' || '01' || '-01', 'yyyy-MM-dd') end) time2from cbm_item_headers a,(select
item_code,to_number(end_year, '9999') + 1
end_year2,to_number(end_month, '99')+1 end_month2 from cbm_item_headers)
cih2 where a.item_code=cih2.item_code) cih2where cih.item_code=cih2.item_code
1 回答

NULL12345
TA貢獻(xiàn)1條經(jīng)驗(yàn) 獲得超0個(gè)贊
case when 前幾個(gè)結(jié)果都是字符串,else結(jié)果是數(shù)學(xué)
- 1 回答
- 0 關(guān)注
- 1091 瀏覽
添加回答
舉報(bào)
0/150
提交
取消