sql报错,怎么改

select b.* from sys_dept a

INNER JOIN ctrl_icc_collect b

on a.dept_finance_id=b.DRAW_INST_NO

where 1=1

and b.open_dt='${time}'

and a.dept_finance_id='${jg}'

${if(a.dept_level= "2",and a.prov_id='${prov}',if(a.dept_level="3",and a.city_id='${city}',if(a.dept_level="4",and a.cnty_id='${cnty}',"")))}

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

select b.* from sys_dept a

INNER JOIN ctrl_icc_collect b

on a.dept_finance_id=b.DRAW_INST_NO

where 1=1

and b.open_dt='${time}'

and a.dept_finance_id='${jg}'

and (case when a.dept_level='2' then a.prov_id when a.dept_level='3' then a.city_id when a.dept_level='4' then a.cnty_id  else '1' end )=(case when a.dept_level='2' then '${prov}' when a.dept_level='3' then '${city}' when a.dept_level='4' then '${cnty}'  else '1' end )

image.png

最佳回答
0
用户6NWif5139660Lv6资深互助
发布于2023-3-3 10:12(编辑于 2023-3-3 10:21)

select b.* from sys_dept a

INNER JOIN ctrl_icc_collect b

on a.dept_finance_id=b.DRAW_INST_NO

where 1=1

and b.open_dt='${time}'

and a.dept_finance_id='${jg}'

${if(a.dept_level= "2","and a.prov_id='"+prov+"'",if(a.dept_level="3","and a.city_id='"+city+"'",if(a.dept_level="4","and a.cnty_id='"+cnty+"'","")))}

image.png

最佳回答
0
用户k6280494Lv6资深互助
发布于2023-3-3 10:18

select b.* from sys_dept a

INNER JOIN ctrl_icc_collect b

on a.dept_finance_id=b.DRAW_INST_NO

where 1=1

and b.open_dt='${time}'

and a.dept_finance_id='${jg}'

${if(a.dept_level= "2","and a.prov_id='"+prov+'",if(a.dept_level="3","and a.city_id='"+city+"'",if(a.dept_level="4","and a.cnty_id='"+cnty+"'","")))}

  • 3关注人数
  • 262浏览人数
  • 最后回答于:2023-3-3 10:21
    请选择关闭问题的原因
    确定 取消
    返回顶部