下拉单选全部项目包含前三个查询出来全部的(必须是单选框)

image.png

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

image.png

SQL

where 1=1 ${if(下拉=="全部项目",""," and 字段 in('"+下拉+"')")}

  • 难过的过 难过的过(提问者) 你这是复选框的,单选的实现不了
    2022-11-07 15:30 
  • Z4u3z1 Z4u3z1 回复 难过的过(提问者) 那不管上面的控件设置,只管SQL
    2022-11-07 15:30 
  • Z4u3z1 Z4u3z1 回复 难过的过(提问者) 你的开盘、常销、尾盘就是全部项目嘛?不会还有其他分类(比如滞销),如果有SQL 要改成 where 1=1 ${if(下拉==\"全部项目\",\" and 字段 IN(\'开盘前\',\'常销期\',\'尾盘期\')\",\" and 字段 in(\'\"+下拉+\"\')\")}
    2022-11-07 15:33 
  • 难过的过 难过的过(提问者) 回复 Z4u3z1 我的数据集里再放$的话就不能执行了 ${IF(LEN(PROJECT)=0, \"SELECT PROJECT_NAME AS 项目, PROJECT_TYPE AS 项目分期, NET_PROFIT_ACT/100000000 AS 动态版净利润, NET_PROFIT_TAR/100000000 AS 方案版净利润, NET_PROFIT_DEVIATION/100000000 AS 净利润偏差, NET_INTEREST_RATE_ACT AS 动态版净利率, NET_INTEREST_RATE_TAR AS 方案版净利率, NET_INTEREST_RATE_DEVIATION AS 净利率偏差, CARGO_VALUE_ACT/100000000 AS 动态版货值, CARGO_VALUE_TAR/100000000 AS 方案版货值, CARGO_VALUE_DEVIATION/100000000 AS 货值偏差, CARGO_COST_ACT/100000000 AS 动态版成本, CARGO_COST_TAR/100000000 AS 方案版成本, CARGO_COST_DEVIATION/100000000 AS 成本偏差 FROM DW_LR_FINANCE_INDEX_BY_PRO WHERE PROJECT_TYPE IN ( \'\" + TYPE + \"\') \", \"WITH WER AS ( SELECT PROJECT_NAME AS PROJECT_NAME, YEAR_MONTHS AS YEAR_MONTHS , NET_PROFIT_ACT/100000000 AS NET_PROFIT_ACT, NET_PROFIT_TAR/100000000 AS NET_PROFIT_TAR, NET_PROFIT_DEVIATION/100000000 AS NET_PROFIT_DEVIATION, NET_INTEREST_RATE_ACT AS NET_INTEREST_RATE_ACT, NET_INTEREST_RATE_TAR AS NET_INTEREST_RATE_TAR, NET_INTEREST_RATE_DEVIATION AS NET_INTEREST_RATE_DEVIATION, CARGO_VALUE_ACT/100000000 AS CARGO_VALUE_ACT, CARGO_VALUE_TAR/100000000 AS CARGO_VALUE_TAR, CARGO_VALUE_DEVIATION/100000000 AS CARGO_VALUE_DEVIATION, CARGO_COST_ACT/100000000 AS CARGO_COST_ACT, CARGO_COST_TAR/100000000 AS CARGO_COST_TAR, CARGO_COST_DEVIATION/100000000 AS CARGO_COST_DEVIATION FROM DW_LR_FINANCE_INDEX_BY_PRO_MONTH WHERE PROJECT_NAME = \'\"+PROJECT+\"\' ) SELECT DISTINCT LEFT(MDM_TIME.FYMDAY,7) AS 年, CASE WHEN RIGHT(CONVERT(VARCHAR(7),MDM_TIME.FYMDAY,120),2)= \'01\' THEN \'1月\' WHEN RIGHT(CONVERT(VARCHAR(7),MDM_TIME.FYMDAY,120),2)= \'02\' THEN \'2月\' WHEN RIGHT(CONVERT(VARCHAR(7),MDM_TIME.FYMDAY,120),2)= \'03\' THEN \'3月\' WHEN RIGHT(CONVERT(VARCHAR(7),MDM_TIME.FYMDAY,120),2)= \'04\' THEN \'4月\' WHEN RIGHT(CONVERT(VARCHAR(7),MDM_TIME.FYMDAY,120),2)= \'05\' THEN \'5月\' WHEN RIGHT(CONVERT(VARCHAR(7),MDM_TIME.FYMDAY,120),2)= \'06\' THEN \'6月\' WHEN RIGHT(CONVERT(VARCHAR(7),MDM_TIME.FYMDAY,120),2)= \'07\' THEN \'7月\' WHEN RIGHT(CONVERT(VARCHAR(7),MDM_TIME.FYMDAY,120),2)= \'08\' THEN \'8月\' WHEN RIGHT(CONVERT(VARCHAR(7),MDM_TIME.FYMDAY,120),2)= \'09\' THEN \'9月\' WHEN RIGHT(CONVERT(VARCHAR(7),MDM_TIME.FYMDAY,120),2)= \'10\' THEN \'10月\' WHEN RIGHT(CONVERT(VARCHAR(7),MDM_TIME.FYMDAY,120),2)= \'11\' THEN \'11月\' WHEN RIGHT(CONVERT(VARCHAR(7),MDM_TIME.FYMDAY,120),2)= \'12\' THEN \'12月\' END AS 项目, -- WER.PROJECT_NAME AS 项目, -- WER.YEAR_MONTHS AS 年月, WER.NET_PROFIT_ACT AS 动态版净利润, WER.NET_PROFIT_TAR AS 方案版净利润, WER.NET_PROFIT_DEVIATION AS 净利润偏差, WER.NET_INTEREST_RATE_ACT AS 动态版净利率, WER.NET_INTEREST_RATE_TAR AS 方案版净利率, WER.NET_INTEREST_RATE_DEVIATION AS 净利率偏差, WER.CARGO_VALUE_ACT AS 动态版货值, WER.CARGO_VALUE_TAR AS 方案版货值, WER.CARGO_VALUE_DEVIATION AS 货值偏差, WER.CARGO_COST_ACT AS 动态版成本, WER.CARGO_COST_TAR AS 方案版成本, WER.CARGO_COST_DEVIATION AS 成本偏差 FROM MDM_TIME LEFT JOIN WER ON WER.YEAR_MONTHS = LEFT(MDM_TIME.FYMDAY,7) WHERE MDM_TIME.FYEAR = CONVERT(VARCHAR(4),GETDATE(),120) \",\"\")}
    2022-11-07 15:34 
  • 难过的过 难过的过(提问者) WHERE PROJECT_NAME = \'\"+PROJECT+\"\'就是这一部分
    2022-11-07 15:35 
最佳回答
0
snrtuemcLv8专家互助
发布于2022-11-7 15:32

直接

select * from 表  where 1=1

${if(下拉框控件名="全部选项","","  and  字段='"+下拉框控件名+"'")}

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

在这段sql后 IN ( '" + TYPE + "') ", if(PROJECT='全部项目'," xxx PROJECT_NAME  in ('开盘前','常销期','尾盘期')","xxxx PROJECT_NAME='"+ PROJECT +"'")

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