執行SQL時 報錯 ORA-01476:divisor is equal to zero 的解決方法
這個報錯,是因為除數為0,可以將除數轉換成非零的整數值
如下面SQL中的紅色部分
with tmp as
(select paycode, transtate, count(1) cnt_1
from elmp_trans_orderinfo
where createtime >= sysdate- 1 / (24 * 12)
and
trantype = 1
group by paycode, transtate)
select channel,case when cnt like '%.%' then to_char(cnt)||'%' else to_char(cnt) end cnt from
(select 'CMB_SUCCESS' channel, nvl(max(case when paycode = '1308' and transtate = 0 then cnt_1 end), 0) cnt
from tmp
union all
select 'CMB_TBD', nvl(max(case when paycode = '1308' and transtate = 2 then cnt_1 end), 0) cnt
from tmp
union all
select 'CMB_FAIL', nvl(max(case when paycode = '1308' and transtate = 1 then cnt_1 end), 0) cnt
from tmp
union all
select 'CMB_SUCCESS_RATIO', round(nvl(max(case when paycode = '1308' and transtate = 0 then cnt_1 end), 0) * 100 /
decode((nvl(max(case when paycode = '1308' and transtate = 0 then cnt_1 end), 0) + nvl(max(case when paycode = '1308' and transtate = 2 then
cnt_1 end), 0) + nvl(max(case when paycode = '1308' and transtate = 1 then cnt_1 end), 0)),0,1), 2)
from tmp
);
如下面SQL中的紅色部分
with tmp as
(select paycode, transtate, count(1) cnt_1
from elmp_trans_orderinfo
where createtime >= sysdate- 1 / (24 * 12)
and
trantype = 1
group by paycode, transtate)
select channel,case when cnt like '%.%' then to_char(cnt)||'%' else to_char(cnt) end cnt from
(select 'CMB_SUCCESS' channel, nvl(max(case when paycode = '1308' and transtate = 0 then cnt_1 end), 0) cnt
from tmp
union all
select 'CMB_TBD', nvl(max(case when paycode = '1308' and transtate = 2 then cnt_1 end), 0) cnt
from tmp
union all
select 'CMB_FAIL', nvl(max(case when paycode = '1308' and transtate = 1 then cnt_1 end), 0) cnt
from tmp
union all
select 'CMB_SUCCESS_RATIO', round(nvl(max(case when paycode = '1308' and transtate = 0 then cnt_1 end), 0) * 100 /
decode((nvl(max(case when paycode = '1308' and transtate = 0 then cnt_1 end), 0) + nvl(max(case when paycode = '1308' and transtate = 2 then
cnt_1 end), 0) + nvl(max(case when paycode = '1308' and transtate = 1 then cnt_1 end), 0)),0,1), 2)
from tmp
);
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-1824320/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 臨時表空間達到幾十G,執行SQL語句報錯解決SQL
- mysql執行sql指令碼報錯ERROR 1366 (HY000) 解決MySql指令碼Error
- idea執行java專案main方法報build failure錯誤的解決方法IdeaJavaAIUI
- spark-submit執行jar包報錯找不到類的解決方法SparkMITJAR
- JDeveloper啟動時老是報錯-解決方法Developer
- 執行Docker命令報錯解決辦法Docker
- Excel宏執行時提示錯誤1004的三個解決方法Excel
- Lumen 實時記錄 SQL 執行解決方案SQL
- mac 下PyCharm執行報錯問題解決MacPyCharm
- docker pull下載映象時的報錯及其解決方法Docker
- win10執行戰地3彈出directx function報錯的解決方法Win10Function
- mydumper執行報錯遇到缺失libssl.so.1.1問題的解決方法
- Docker Hello World容器執行報錯的解決辦法Docker
- 幾個報錯的解決方法
- Windows 使用者執行 NPM run watch-poll 報錯的原因及解決方法WindowsNPM
- 執行dbca命令的時候報錯了
- linux執行sh報錯:$’\r’: 未找到命令的解決Linux
- 同時多個SQL命令執行的方法SQL
- hive使用報錯解決方法Hive
- 執行create table as 報ora-600的錯誤的解決方案
- LoadRunner在執行時常見的提示錯誤和解決方法
- Laravel Mix執行時關於es2015報錯解決方案Laravel
- 應用儲存過程執行報錯解決方案儲存過程
- Laravel Mix - 執行 NPM install 報錯解決辦法LaravelNPM
- sqlplus執行sql檔案報錯SQL
- SYS執行SQL報錯缺少許可權SQL
- 在unix下定時執行oracle的sql方法(轉)OracleSQL
- dbfread報錯ValueError錯誤解決方法Error
- ***XAMPP:報錯Unabletoloaddynamiclibrary的解決方法
- 在 11.2.0.4 執行 utlrp.sql 出現 ORA-04031 錯誤解決方法SQL
- 解決TOAD中執行計劃顯示報錯的問題
- mongoDB的db.shutdownServer()報錯的解決方法MongoDBServer
- 誰遇到過執行 monkey 的時候報 filenotfound 的報錯
- win10系統執行CSGO時藍屏的解決方法Win10Go
- 解決因對EFCore執行SQL方法不熟練而引起的問題SQL
- 執行impdp時出現ORA-39154錯誤的解決案例
- AS執行main()方法報錯:SourceSet with name ‘main‘ not foundAI
- Mybatis批量更新SQL報錯☞解決辦法MyBatisSQL