me lo esta tirando como quiero en columnas distintas pero el resultado lo esta sumando me entrega los años sumandos como resultado
Código PHP:
select case when a.mes=12 then 'Diciembre'else
case when a.mes=1 then'Enero'else
case when a.mes=2 then'Febrero' end end end as mes,
sum(a.prima_us_PC) as prima_us_PC,sum(a.prima_us_BU) as prima_us_BU,sum(a.prima_us_PC) as prima_us_PC1,sum(a.prima_us_BU) as prima_us_BU1 from
(select mes ,sum (prima_us) as prima_us_PC,sum (0) as prima_us_BU
from produ_comercial
where
(manager = 'L'and cia ='000169'and mes = 12 AND year IN (2008))
or
(manager = 'L'and mes in ('1','2') and cia ='000169'AND year IN (2009) )
group by mes
union
(select mes ,sum (prima_us) as prima_us_PC1,sum (0) as prima_us_BU1
from produ_comercial
where
(manager = 'L'and cia ='000169'and mes = 12 AND year IN (2009))
or
(manager = 'L'and mes in ('1','2') and cia ='000169'AND year IN (2010) )
group by mes))a
group by a.mes