我使用spagobi和oracle DBMS但是当我想获得2010年到2014年之间的值时出现错误:右括号丢失
select (sum(d.taux_depot *100)/count(r.trimestre) ) as taux , trimestre as trimestre
from datamart_cnss d , ref_temps r
where d.ID_TEMPS = r.ID_TEMPS
and (case when $P{anneecnss}=123 then (r.annee between 2010 and 2014 ) else $P{anneecnss} end) = r.annee
and (case when To_CHAR($P{regimecnss})=123 then To_CHAR(d.id_regime) else To_CHAR($P{regimecnss}) end) = To_CHAR(d.id_regime)
and (case when To_CHAR($P{bureau_cnss})=123 then To_CHAR(d.id_bureau) else To_CHAR($P{bureau_cnss}) end) = To_CHAR(d.id_bureau)
group by trimestre
order by trimestre asc
谢谢
答案 0 :(得分:0)
这不是有效的构造:
case when $P{anneecnss}=123 then (r.annee between 2010 and 2014 ) else $P{anneecnss} end
你不能在then
部分内有一个条件,只是一个值或表达式,然后你可以将它与其他东西进行比较。
要有选择地应用该过滤器,您不需要使用案例陈述,请使用and
和or
;我认为这是等价的:
where d.ID_TEMPS = r.ID_TEMPS
and (($P{anneecnss} = 123 and r.annee between 2010 and 2014)
or ($P{anneecnss} != 123 and $P{anneecnss} = r.annee))
and ($P{regimecnss} = 123 or To_CHAR($P{regimecnss}) = To_CHAR(d.id_regime))
and ($P{bureau_cnss} = 123 or To_CHAR($P{bureau_cnss}) = To_CHAR(d.id_bureau))
...