Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/03/2014, 06:36
facundojr07
 
Fecha de Ingreso: enero-2013
Mensajes: 64
Antigüedad: 11 años, 10 meses
Puntos: 0
Consulta MySQL Sumar distintas tablas

Buenos dias,

Les hago la siguiente consulta. Lo que quiero generer es una suma de columnas en distintas tablas.

He generado el siguiente código y me funciona
Código MySQL:
Ver original
  1. SELECT START, SUM(Mbps_DL_hpps) AS Suma_total, SUM(Mbps_UL_hpps) AS Sum_total2
  2. SUM(trafico_datos_R99_DL+trafico_datos_HSDPA)*8/3600 AS Mbps_DL_hpps,
  3. SUM(trafico_datos_R99_UL+trafico_datos_HSUPA)*8/3600 AS Mbps_UL_hpps
  4. FROM Estadisticas_UMTS.RAN_UCELL_hpps
  5. WHERE START>=('2014-03-01') GROUP BY START
  6. SUM(DL_PS_R99_Bytes+HSDPA_RLC_Traffic)/1024/1024*8/3600 AS Mbps_DL_hpps,
  7. SUM(UL_PS_R99_Bytes+HSUPA_RLC_Traffic)/1024/1024*8/3600 AS Mbps_UL_hpps
  8. FROM Estadisticas_UMTS.KPI_Trafico_cell_hpps  
  9. WHERE START>=('2014-03-01') GROUP BY START
  10. )

Pero como son varias Tablas las que quiero sumar, he generado el siguiente codigo que no me funciona:
Código MySQL:
Ver original
  1. SELECT START, SUM(Erlangs_voz_hpcs) AS Suma_total, SUM(Mbps_DL_hpps) AS Suma_total, SUM(Mbps_UL_hpps) AS Sum_total2
  2. SELECT START, SUM(trafico_voz) AS Erlangs_voz_hpcs
  3. FROM Estadisticas_UMTS.RAN_UCELL_hpcs
  4. WHERE START>=('2014-03-01') GROUP BY START
  5. SELECT START, SUM(AMR_Traffic) AS Erlangs_voz_hpcs
  6. FROM Estadisticas_UMTS.KPI_Trafico_cell_hpcs
  7. WHERE START>=('2014-03-01') GROUP BY START
  8. SUM(trafico_datos_R99_DL+trafico_datos_HSDPA)*8/3600 AS Mbps_DL_hpps,
  9. SUM(trafico_datos_R99_UL+trafico_datos_HSUPA)*8/3600 AS Mbps_UL_hpps
  10. FROM Estadisticas_UMTS.RAN_UCELL_hpps
  11. WHERE START>=('2014-03-01') GROUP BY START
  12. SUM(DL_PS_R99_Bytes+HSDPA_RLC_Traffic)/1024/1024*8/3600 AS Mbps_DL_hpps,
  13. SUM(UL_PS_R99_Bytes+HSUPA_RLC_Traffic)/1024/1024*8/3600 AS Mbps_UL_hpps
  14. FROM Estadisticas_UMTS.KPI_Trafico_cell_hpps  
  15. WHERE START>=('2014-03-01') GROUP BY START
  16. )

La consulta es cual es mi error en la segunda consulta que no devuelve resultados.

Muchas gracias. Saludos.

Última edición por gnzsoloyo; 07/03/2014 a las 07:18