当‘月份’传入的参数不是2021时,我要执行另外一个sql。该怎么写啊?我外面已经有一层其他的判断了

image.png

${if(len(等级)==0,

"select roast_season,left(area_company,2)as area_company1,AVG(standard_stem_rate),sum(check_amount) from physics_check

where work_month in ('"+月份+"')  AND area_company is not null and roast_season='"+烤季+"'

group by  roast_season,area_company1",

"select roast_season,left(area_company,2)as area_company1,smoke_level,AVG(standard_stem_rate),sum(checka_amount) from physics_check

where work_month in ('"+月份+"') and smoke_level='"+等级+"' and roast_season='"+烤季+"'

AND area_company is not null 

group by  roast_season,area_company1,smoke_level")}

FineReport 用户N1887570 发布于 2022-2-17 10:52
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共3回答
最佳回答
0
沉默的反补Lv6中级互助
发布于2022-2-17 10:54(编辑于 2022-2-17 11:10)

解决方案:

制作两张模板,模板1对应烤季参数为1的情况下的数据,模板2队友烤季参数为2的情况下的数据,然后使用网页框判断烤季参数值,if($烤季=1,url1,url2),以下图片仅供参考,实则处理逻辑一样。

image.png

最佳回答
0
CD20160914Lv8专家互助
发布于2022-2-17 11:00(编辑于 2022-2-17 11:03)

${if(len(等级)==0,

"select roast_season,left(area_company,2)as area_company1,AVG(standard_stem_rate),sum(check_amount) from physics_check

where work_month in ('"+月份+"') 

AND area_company is not null 

and roast_season='"+烤季+"'

group by  roast_season,area_company1",

"select roast_season,left(area_company,2)as area_company1,smoke_level,AVG(standard_stem_rate),sum(checka_amount) from physics_check

where work_month in ('"+月份+"') 

and smoke_level='"+等级+"' 

and roast_season='"+烤季+"'

AND area_company is not null 

group by  roast_season,area_company1,smoke_level")}

image.png

image.png

  • 用户N1887570 用户N1887570(提问者) 没发现变化了,是不是发错了。。。
    2022-02-17 11:01 
  • CD20160914 CD20160914 回复 用户N1887570(提问者) 没有呀。你可以预览看。。。不录入等级。它的sql执行情况
    2022-02-17 11:01 
  • 用户N1887570 用户N1887570(提问者) 回复 CD20160914 。。。 不是等级 我现在还要个判断。当录入的\'烤季\'不是 2021时,我需要执行另外一个sql。
    2022-02-17 11:03 
  • CD20160914 CD20160914 回复 用户N1887570(提问者) 看我上面补充的图片,没有录入等级与录入等级最后得到的sql语句。。。
    2022-02-17 11:03 
  • CD20160914 CD20160914 回复 用户N1887570(提问者) 大哥,你的判断只判断了等级为空的情况呀。。。你还要再判断什么???一起说完
    2022-02-17 11:05 
最佳回答
0
Z4u3z1Lv6专家互助
发布于2022-2-17 11:09

使劲套娃

${if(len(等级)==0,/*等级为空*/if(月份==2021,/*等级为空,月份为2021*/SQL1,/*等级为空,月份不为2021*/SQL2),/*等级不为空*/if(月份==2021,/*等级不为空,月份为2021*/SQL3,/*等级为空月份不为2021*/SQL4))}

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