数据集里面${if}里面嵌套if怎么写

if嵌套怎么写? 双引号的位置有问题

${if(A=="角色1","select 字段1,字段2 from 表 aa where 1=1 ${if(len(状态)==0,"","and type='"+状态+"'")}",if(A=="角色2","select 字段1,字段2 from 表bb ",""))}

FineReport yunliwuli 发布于 2022-11-30 13:46 (编辑于 2022-11-30 15:04)
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共3回答
最佳回答
4
Z4u3z1Lv6专家互助
发布于2022-11-30 13:48

${if(A=="角色1","select 字段1,字段2 from 表 aa where 1=1"+ IF(len(状态)==0,""," AND type='"+状态+"'"),if(A=="角色2","select 字段1,字段2 from 表bb ",""))}

最佳回答
1
Leonard.LinLv5初级互助
发布于2022-11-30 14:20(编辑于 2022-11-30 14:21)

${IF(pRESOURCE_TYPE = '现存已配车',"

select 

calculation_method,

car_series,

car_model,

sum(allocation_predict_qty) as qty

from 

dal.dal_dvmp_delivery_forecast_fr

where 1=1 "

+if(len(pMETHOD) == 0,"","and calculation_method  IN ('" +pMETHOD + "')")+

"group by car_series,calculation_method,

car_model",

"select 

car_series,

car_model,

sum(allocation_predict_qty) as qty

from

dal.dal_dvmp_delivery_forecast_fr

group by car_series,

car_model

"

)}

替换一下即可

最佳回答
0
用户k6280494Lv6资深互助
发布于2022-11-30 14:15

${if(and(A=="角色1",len(状态)>0),"select 字段1,字段2 from 表 aa where type='"+状态+"'",if(and(A=="角色1",len(状态)=0),"select 字段1,字段2 from 表 aa",if(A=="角色2","select 字段1,字段2 from 表bb ","")))}

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