Ver Mensaje Individual
  #2  
Antiguo 10-09-2008
Avatar de kuan-yiu
[kuan-yiu] kuan-yiu is offline
Miembro Premium
 
Registrado: jun 2006
Ubicación: Galicia. España.
Posts: 1.017
Reputación: 19
kuan-yiu Va camino a la fama
Pues con un "group by" y un "union". Hay otras soluciones pero creo que te vale algo así:
Código SQL [-]
select NombreSub, sum(prepago), sum(pospago)
from
(select NombreSub, 1 as prepago, 0 as pospago
from tabla
where tipoplan='prepago'
union
select NombreSub, 0 as prepago, 1 as pospago
from tabla
where tipoplan='pospago')
group by Nomsub
order by 3
Responder Con Cita