添加数据库查询,执行判断报错

想要的是:点击图表会传过来两个参数一个是Type(已填报、未填报),一个是日期Year_Month(2024-06),然后判断Type是不是已填报的是的话执行后边第一个的语句,不是的话执行后边的那个语句!现在执行就报这个错误!有了没有大佬知道一下应该怎么写才行!

${if(len(Type) == 0,"","")} 

图一:

image.png

图2:

image.png

FineReport SSVIP 发布于 2024-7-5 14:13 (编辑于 2024-7-5 14:30)
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共1回答
最佳回答
1
华莉星宸Lv7高级互助
发布于2024-7-5 14:15

直接把你的SQL贴出来

这里面写错了,要拼接

image.png

  • SSVIP SSVIP(提问者) select "建设" as 部门, COUNT(*) 需求数量 FROM ( select * from view_HZLHRS_TrainingNeeds as b left join view_DiGuiDpartData as a on a.dpartId = b.tn_Depart where tn_DocumentStatus in (1,2) AND tn_CreateDate >=DATEADD(month, 0,convert(datetime,'${Year_Month}'+"-01")) AND tn_CreateDate< DATEADD(DAY,1,EOMONTH('${Year_Month}'+"-01")) AND TopLevelDepartmentID = 3 ) as T GROUP BY TopLevelDepartmentdpartName 要怎么改呀
    2024-07-05 14:17 
  • 华莉星宸 华莉星宸 回复 SSVIP(提问者) 参考这个格式改 ${if(len(a)=0,"select '建设' as 部门, COUNT(*) 需求数量 FROM ( select * from view_HZLHRS_TrainingNeeds as b left join view_DiGuiDpartData as a on a.dpartId = b.tn_Depart where tn_DocumentStatus in (1,2) AND tn_CreateDate >=DATEADD(month, 0,convert(datetime,"+Year_Month+"-01)) AND tn_CreateDate< DATEADD(DAY,1,EOMONTH('"+Year_Month+"-01)) AND TopLevelDepartmentID = 3 ) as T GROUP BY TopLevelDepartmentdpartName",'')}
    2024-07-05 14:22 
  • SSVIP SSVIP(提问者) 回复 华莉星宸 大佬,帮忙看一下上面的图2是啥问题呀 ${if(Type == "已填报"," select '建设' as 部门, COUNT(*) 需求数量 FROM ( select * from view_HZLHRS_TrainingNeeds as b left join view_DiGuiDpartData as a on a.dpartId = b.tn_Depart where tn_DocumentStatus in (1,2) AND tn_CreateDate >=DATEADD(month, 0,convert(datetime,"+Year_Month+"-01)) AND tn_CreateDate< DATEADD(DAY,1,EOMONTH("+Year_Month+"-01)) AND TopLevelDepartmentID = 3 ) as T GROUP BY TopLevelDepartmentdpartName ","")}
    2024-07-05 14:32 
  • 华莉星宸 华莉星宸 回复 SSVIP(提问者) ${if(Type == "已填报"," select '建设' as 部门, COUNT(*) 需求数量 FROM ( select * from view_HZLHRS_TrainingNeeds as b left join view_DiGuiDpartData as a on a.dpartId = b.tn_Depart where tn_DocumentStatus in (1,2) AND tn_CreateDate >=DATEADD(month, 0,convert(datetime,'"+Year_Month+"-01')) AND tn_CreateDate< DATEADD(DAY,1,EOMONTH('"+Year_Month+"-01')) AND TopLevelDepartmentID = 3 ) as T GROUP BY TopLevelDepartmentdpartName ","")}
    2024-07-05 14:35 
  • SSVIP SSVIP(提问者) 回复 华莉星宸 谢谢大佬
    2024-07-05 14:39 
  • 2关注人数
  • 156浏览人数
  • 最后回答于:2024-7-5 14:30
    请选择关闭问题的原因
    确定 取消
    返回顶部