Ver Mensaje Individual
  #25 (permalink)  
Antiguo 13/05/2009, 11:00
Avatar de Dradi7
Dradi7
 
Fecha de Ingreso: junio-2008
Ubicación: Peru - Lima
Mensajes: 1.518
Antigüedad: 16 años, 9 meses
Puntos: 220
Respuesta: Separar y sumar datos de una misma columna

Otra Forma de como Hacerlo
Código sql:
Ver original
  1. SELECT Factura,Movil,ISNULL([BAM],0) AS BAM,ISNULL([MMS],0) AS MMS,ISNULL([RPV],0) AS RPV,
  2.        ISNULL([SME],0) AS SME,ISNULL([SMR],0) AS SMR,ISNULL([TEL],0) AS TEL,
  3.        ISNULL([TLL],0) AS TLL,
  4.        ([BAM] + [MMS] + [RPV] + [SME] + [SMR] + [TEL] + [TLL]) AS TOTAL
  5. FROM
  6. (
  7.     SELECT Factura,Movil,Servicio FROM Trafico
  8. ) V PIVOT (SUM(VALOR + AGREGADO) FOR SERVICIO IN([BAM],[MMS],[RPV],[SME],[SMR],[TEL],[TLL])) AS PT
  9. ORDER BY FACTURA,MOVIL
__________________
La clave de todo triunfador es eliminar todas sus excusas y sus limitaciones