SQL..

select

Flfxdj,

count(*) as num

from lg_det_lril

WHERE  1=1

${if("SELECT  distinct Category_Name  FROM `DIM_DEPT` where Organization in ('"+Units_Involved+"')=='集团职能中心'","and Units_Involved in('各单位')","and Units_Involved in('各业务单元','各单位')")}

group by Flfxdj

在if判断里面,我要根据参数Units_Involved去得到查询结果再判断,而不是直接根据参数判断,目前这样写,不管输入满足还是不满足的参数条件,最终输出的结果都是false,也就是根据后面的条件去查询;需要怎么调整或者还是不能这样写

dlb 发布于 2022-2-24 19:25
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共1回答
最佳回答
0
zsh331Lv8专家互助
发布于2022-2-24 19:32

select

Flfxdj,

count(*) as num

from lg_det_lril

WHERE  1=1

${if(sql("SELECT distinct Category_Name  FROM DIM_DEPT where Organization in ('"+Units_Involved+"',1,1)")='集团职能中心'," and Units_Involved in('各单位')"," and Units_Involved in('各业务单元','各单位')")}

group by Flfxdj

——————————————————————————

  • dlb dlb(提问者) select Flfxdj, count(*) as num from lg_det_lril WHERE 1=1 ${if(sql(\"连接名称\",\"SELECT distinct Category_Name FROM DIM_DEPT where Organization_Name in (\'\"+Units_Involved+\"\')\",1,1)==\'集团职能中心\',\" and Units_Involved in(\'各单位\')\",\" and Units_Involved in(\'各业务单元\',\'各单位\')\")} group by Flfxdj
    2022-02-24 21:04 
  • 2关注人数
  • 275浏览人数
  • 最后回答于:2022-2-24 19:32
    请选择关闭问题的原因
    确定 取消
    返回顶部