select en horizontal

19/11/2009 - 20:47 por Luis Mata | Informe spam
Hola
se puede poner esto:

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
 

Leer las respuestas

#1 rgarrigos-sinesto
19/11/2009 - 21:12 | Informe spam
Hola 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

Hola
se puede poner esto:
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

Preguntas similares