select sum(total) as tot_efe from tabla where tpago='efe'
y
select sum(total) as tot_cre from tabla where tpago='cre'
los resultados ponerlo en una sola tabla:
tot_efe tot_cre
150 55
Luis
select
sum(case when tpago='efe' then total else 0 end) as tot_efe,
sum(case when tpago='cre' then total else 0 end) as tot_cre
from
tabla
where
tpago='efe' or tpago='cre'
Un saludo,
Rub�n Garrig�s
Solid Quality Mentors
Blog: http://blogs.solidq.com/es/elrincondeldba
select
(select sum(total) as tot_efe from tabla where tpago='efe') as tot_efe,
(select sum(total) as tot_cre from tabla where tpago='cre') as tot_cre
Tambien puedes hacerlo de la sgte manera:
select
sum(case when tpago = 'efe' then total else 0 end) as tot_efe,
sum(case when tpago = 'cre' then total else 0 end) as tot_cre
from
tabla
where
tpago in ('efe', 'cre');
AMB
"Luis Mata" wrote:
> .
>