数据集参数

请问各位大佬,怎么在数据集里加参数,可以实现传不同的参数查不同段的sql

比如筛选框是周期,有周和月两个选项,选择周时,数据集里选择周那一段,选择月时,数据集里选择月那一段

FineReport yzm313451 发布于 2024-3-22 13:15
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共2回答
最佳回答
0
用户k6280494Lv6资深互助
发布于2024-3-22 13:17(编辑于 2024-3-22 13:43)

${if(cs='周',"select * from a","select * from b")}

${if(cs='周',"select * from a where rq='"+rq+"'",if(cs='',"select * from b","select * from b"))}

  • yzm313451 yzm313451(提问者) 如果有超过两个选项改用switch吗
    2024-03-22 13:19 
  • 用户k6280494 用户k6280494 回复 yzm313451(提问者) 可以,也可以在写if
    2024-03-22 13:20 
  • yzm313451 yzm313451(提问者) 这个是不是控件名为cs,但是这样些好像筛选框的值传不进去
    2024-03-22 13:31 
  • yzm313451 yzm313451(提问者) with temp as ( select case when update_time >= date_format(update_time,\'%Y-%m-%d 08:00:00\') and update_time < date_format(update_time,\'%Y-%m-%d\') + interval \'1440\' minute then date_format(update_time,\'%Y-%m-%d\') else (date_format(update_time,\'%Y-%m-%d\')- interval \'1\' day) end as report_date, efficiency, num from `cell-mes`.`pack_package` where 1=1 and efficiency <>\'/\' ) select * from ( ${if(zq=\'周度\',\"select concat(\'W\',week(report_date,1)) as index_x, concat(efficiency,\'%\') as efficiency, sum(num)/10000 as num , sum(num)/sum(sum(num)) over() as proportion from temp where yearweek(report_date,1) >= yearweek(\'${select_date}\',1)-4 and yearweek(report_date,1) <= yearweek(\'${select_date}\',1) and report_date = substring_index(\'${select_date}\' - interval \'4\' month,\'-\',2) group by concat(substring_index(report_date,\'-\',2),\'月\'),efficiency\")} )m order by case when m.index_x like \'%月%\' then 1 when m.index_x like \'%W%\' then 2 else 3 end asc ,case when index_x like \'W%\' then replace(index_x,\'W\',\'\')+0 else null end asc ,m.index_x asc
    2024-03-22 13:35 
  • yzm313451 yzm313451(提问者) 大佬帮忙看下哪里不对
    2024-03-22 13:36 
最佳回答
0
ID1208Lv6高级互助
发布于2024-3-22 13:18(编辑于 2024-3-22 13:18)

数据集sql参数用开始日期和结束日期

参考--https://help.fanruan.com/finereport/doc-view-2930.html

  • 3关注人数
  • 132浏览人数
  • 最后回答于:2024-3-22 13:43
    请选择关闭问题的原因
    确定 取消
    返回顶部