Z4u3z1 回复 难过的过(提问者)你的开盘、常销、尾盘就是全部项目嘛?不会还有其他分类(比如滞销),如果有SQL 要改成
where 1=1 ${if(下拉==\"全部项目\",\" and 字段 IN(\'开盘前\',\'常销期\',\'尾盘期\')\",\" and 字段 in(\'\"+下拉+\"\')\")}
难过的过(提问者) 回复 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) \",\"\")}