=SWITCH(Parameters!date_range_type.Value = "WEEKLY", IIF((cInt(Parameters!WW2.Value) - cInt(Parameters!WW1.Value)) > 10, Parameters!WW1.Value,IIF(cInt(Parameters!WW2.Value) < 11,1,cInt(Parameters!WW2.Value) - 10)),
Parameters!date_range_type.Value = "MONTHLY", IIF((cInt(MONTH(datepart("YYYY",today())& "-" & Parameters!WW2.Value & "-01")) - cInt(MONTH(datepart("YYYY",today())& "-" & Parameters!WW1.Value & "-01"))) > 10, MONTH(datepart("YYYY",today())& "-" & Parameters!WW1.Value & "-01"),IIF(cInt(MONTH(datepart("YYYY",today())& "-" & Parameters!WW2.Value & "-01")) < 11,1,cInt(MONTH(datepart("YYYY",today())& "-" & Parameters!WW2.Value & "-01")) - 10))
)
如果我只为'WEEKLY'运行报告,意味着不需要切换和其他iif条件,它工作正常。只在'MONTHLY'上运行时也是如此。
修改
如果我只使用iif,这就是它的样子..
IIF(Parameters!date_range_type.Value = "MONTHLY",( IIF((cInt(MONTH(datepart("YYYY",today())& "-" & Parameters!WW2.Value & "-01")) - cInt(MONTH(datepart("YYYY",today())& "-" & Parameters!WW1.Value & "-01"))) > 10,MONTH(datepart("YYYY",today())& "-" & Parameters!WW1.Value & "-01"),IIF(cInt(MONTH(datepart("YYYY",today())& "-" & Parameters!WW2.Value & "-01")) < 11,1,cInt(MONTH(datepart("YYYY",today())& "-" & Parameters!WW2.Value & "-01")) - 10)) ),
( IIF(Parameters!date_range_type.Value = "WEEKLY",( IIF((cInt(Parameters!WW2.Value) - cInt(Parameters!WW1.Value)) > 10, Parameters!WW1.Value,
IIF(cInt(Parameters!WW2.Value) < 11,1,cInt(Parameters!WW2.Value) - 10)) ), "0") ) )
答案 0 :(得分:0)
最终使用sql函数完成作业。这与上面的SSRS代码逻辑相同。
CREATE OR REPLACE FUNCTION ww3_param (ww1 IN NUMBER, ww2 IN NUMBER)
RETURN VARCHAR2
IS
ret_val VARCHAR2(10);
BEGIN
IF (ww2 - ww1) > 10 THEN
ret_val := to_char(ww1);
ELSE
IF ww2 < 10 THEN
ret_val := '1';
ELSE
ret_val := to_char(ww2 - 10);
END IF;
END IF;
RETURN ret_val;
END;
修改强>
这是数据集的查询:
select case when :date_range_type = 'MONTHLY' then ww3_param(to_char(to_date(:WW1,'MON'),'MM'),to_char(to_date(:WW2,'MON'),'MM'))
when :date_range_type = 'WEEKLY' then ww3_param(to_number(:WW1),to_number(:WW2)) end as ww3_param_value
from dual