开发者社区> 问答> 正文

DB2 查询中进行计算( (M.JSSL/M.JHSG*100) )报错,不知道什么原因?报错

查询时,加了进行计算(红色字体),怎么会报错了,不明白

SELECT M.DWDM,M.DWMC,M.JHSG,M.SJMJ,M.JSSL,M.ZZMJ, (M.JSSL/M.JHSG*100) AS JSSLPROCESS FROM (SELECT F.DWDM,F.DWMC,SUM(F.JHSG) AS JHSG,SUM(F.SJMJ) AS SJMJ,SUM(CASE WHEN P.JSSL IS NULL THEN 0.00 ELSE P.JSSL END) AS JSSL, SUM(CASE WHEN P.ZZMJ IS NULL THEN 0.00 ELSE P.ZZMJ END) AS ZZMJ,SUM(P.NUM) AS NUM FROM (SELECT S.C_DWDM AS DWDM,S.C_DWDM AS DWMC,SUM(S.P_JHSG) AS JHSG,SUM(S.P_SJMJ) SJMJ FROM YY_SG.SGJH S WHERE (C_CHECK='1' or C_CHECK='9') AND (COMM <> '2' AND COMM <> '5') GROUP BY S.C_DWDM,S.C_DWDM) F LEFT JOIN(SELECT X.PROVDWDM AS DWDM,X.PROVDWMC AS DWMC,SUM(L.ZZMJ*L.LXFH) AS ZZMJ,SUM(L.JSSL*L.LXFH) AS JSSL,COUNT(DISTINCT L.HTH) AS NUM FROM YY_SC.XJSZ X,YY_SC.XJSZLX L WHERE X.KEYNO=L.KEYNO GROUP BY X.PROVDWDM,X.PROVDWMC) P ON F.DWDM = P.DWDM GROUP BY F.DWDM,F.DWMC) M

错误:


[Error Code: -419, SQL State: 42911]  DB2 SQL Error: SQLCODE=-419, SQLSTATE=42911, SQLERRMC=null, DRIVER=4.15.82. 2) [Error Code: -727, SQL State: 56098]  DB2 SQL Error: SQLCODE=-727, SQLSTATE=56098, SQLERRMC=2;-419;42911;, DRIVER=4.15.82




展开
收起
爱吃鱼的程序员 2020-06-14 22:14:33 576 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    看了错误代码说是,十进制除法无效,难道是除数不能为字段?还是说怕除数为0

    2020-06-14 22:14:52
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
PolarDB NL2SQL: 帮助您写出准确、优化的SQL 立即下载
HTAP DB HTAP DB —System : ApsaraDB HBase Phoenix and Spark 立即下载
低代码开发师(初级)实战教程 立即下载