查询报错

总是出java.lang.NullPointerException,求各位大佬看看为啥出错

代码如下

select CS2,code,name,jg  from

(select case when ("'${pz}'" = "'115'" or "'${pz}'" ="'103'" ) then jg_q else jg_c end as jg, CS2,code,name from

  (select  a.code, a.name, a.jg_q, a.jg_c ,b.CS2 

  from app_yp.jc_ORC a

  join ALL_D05.ERP_GRAPH_ORC b on a.code= b.zxnjg

  where A.CALDAY = REPLACE('${date}' ,'-','')

  ${IF(pz=="",""," AND A.CS2 IN ("+pz+")")}

  group by b.CS2)

group by CS2)

FineReport 用户x076327 发布于 2022-7-19 14:36
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共5回答
最佳回答
0
CD20160914Lv8专家互助
发布于2022-11-2 20:15

字段一般不用单号而且你还套了双引号。同时你的替换日期的函数没用对

SELECT CS2,code,NAME,jg  FROM

(SELECT CASE WHEN (${pz} = '115' OR ${pz} ='103' ) THEN jg_q ELSE jg_c END AS jg, CS2,code,NAME FROM

  (SELECT  a.code, a.NAME, a.jg_q, a.jg_c ,b.CS2

  FROM app_yp.jc_ORC a

  JOIN ALL_D05.ERP_GRAPH_ORC b ON a.code= b.zxnjg

  WHERE A.CALDAY = ${Replace(date ,'-','')}

  ${IF(pz=="",""," AND A.CS2 IN ("+pz+")")}

  GROUP BY b.CS2)a

GROUP BY CS2)b

image.png

最佳回答
0
好好生活好好学习Lv7资深互助
发布于2022-7-19 14:37(编辑于 2022-7-19 14:37)

where A.CALDAY = '${REPLACE(date,"-","")}'

image.png

最佳回答
0
lxy2Lv6中级互助
发布于2022-7-19 14:38

SELECT CS2,code,NAME,jg  FROM

(SELECT CASE WHEN ('${pz}' = '115' OR '${pz}' ='103' ) THEN jg_q ELSE jg_c END AS jg, CS2,code,NAME FROM

  (SELECT  a.code, a.NAME, a.jg_q, a.jg_c ,b.CS2

  FROM app_yp.jc_ORC a

  JOIN ALL_D05.ERP_GRAPH_ORC b ON a.code= b.zxnjg

  WHERE A.CALDAY = Replace('${date}' ,'-','')

  ${IF(pz=="",""," AND A.CS2 IN ("+pz+")")}

  GROUP BY b.CS2)a

GROUP BY CS2)b

最佳回答
0
Z4u3z1Lv6专家互助
发布于2022-7-19 14:41

这两个是115还是'115'   ??

image.png

最佳回答
0
yzm339714Lv6中级互助
发布于2022-7-19 14:44

最里面的一层select 没有加反括号把

select CS2,code,name,jg  from

(select case when ("'${pz}'" = "'115'" or "'${pz}'" ="'103'" ) then jg_q else jg_c end as jg, CS2,code,name from

  (select  a.code, a.name, a.jg_q, a.jg_c ,b.CS2 

  from app_yp.jc_ORC a

  join ALL_D05.ERP_GRAPH_ORC b on a.code= b.zxnjg

  where A.CALDAY = REPLACE('${date}' ,'-','')

  ${IF(pz=="",""," AND A.CS2 IN ("+pz+")")})

  group by b.CS2)

group by CS2)

  • 5关注人数
  • 405浏览人数
  • 最后回答于:2022-11-2 20:15
    请选择关闭问题的原因
    确定 取消
    返回顶部