-1

我将 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

谢谢

4

1 回答 1

0

这不是一个有效的构造:

case when $P{anneecnss}=123 then (r.annee between 2010 and 2014 )  else $P{anneecnss} end

您不能在then零件内有条件,而只能是一个值或表达式,然后您可以将其与其他内容进行比较。

要有选择地应用该过滤器,您不需要使用 case 语句,使用andand 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))
...
于 2015-03-04T17:44:26.210 回答