sql函数

sql("SampleDashboard","select count(distinct office_name,model_name,category_name) totalCount from ProStateDetail 

where ${if(len(ts_xh)=0,'1=1','model_name like "%'+ts_xh+'%" ')} and category_name in ('"+ts_pl+"') and category_model_state='"+is_ts+"' ",1,1)


这里面的if该怎么使用?

FineReport pengfuqiang96 发布于 2020-12-11 13:38
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共3回答
最佳回答
0
朝赟丶Lv6初级互助
发布于2020-12-11 13:41
=sql("FRDemo","SELECT * FROM STSCORE where 1=1 "+if(len(p1)== 0,"","and CLASSNO = '"+p1+"'"),3,4)

参考这个文档

https://help.fanruan.com/finereport/doc-view-846.html?source=1

  • pengfuqiang96 pengfuqiang96(提问者) var sql = \"select count(distinct office_name,model_name,category_name) totalCount from ProStateDetail where category_name in (\'\"+ts_pl+\"\')and category_model_state=\'\"+is_ts+\"\' \" + if(len(ts_xh)=0,\"and 1=1\",\"and model_name like \'%\"+ts_xh+\"%\' \"); var s = \'sql(\"SampleDashboard\",\"\' + sql + \'\",1,1)\'; var totalCount = FR.remoteEvaluate(s); 还是跑不出来
    2020-12-11 14:05 
最佳回答
0
snrtuemcLv8专家互助
发布于2020-12-11 13:43
sql("SampleDashboard","select count(distinct office_name,model_name,category_name) totalCount from ProStateDetail 
where "+if(len(ts_xh)=0,"1=1","model_name like '%"+xh+"% '")+ 
"and category_name in ('"+ts_pl+"') and category_model_state='"+is_ts+"' ",1,1)


最佳回答
0
AmyQLv6初级互助
发布于2020-12-11 13:43

sql("SampleDashboard","select count(distinct office_name,model_name,category_name) totalCount from ProStateDetail where 1=1 ${if(len(ts_xh)=0,'','model_name like "%'+ts_xh+'%" ')} and category_name in ('"+ts_pl+"') and category_model_state='"+is_ts+"' ",1,1)

  • 4关注人数
  • 434浏览人数
  • 最后回答于:2020-12-11 13:43
    请选择关闭问题的原因
    确定 取消
    返回顶部