Ver Mensaje Individual
  #7  
Antiguo 08-06-2013
Avatar de santiago14
santiago14 santiago14 is offline
Miembro
 
Registrado: sep 2003
Ubicación: Cerrillos, Salta, Argentina
Posts: 583
Reputación: 21
santiago14 Va por buen camino
Post

Tienen razón, las formas de envío están en la tabla SUSCRIPCIONES. Esto fue un error que cometí hace años , quedó así y hoy es muy pero muy difícil modificar la BD. Es grande y de un gran uso...

Algo que me funcionó fue esto:
Código SQL [-]
Select COALESCE(SUM(s.CANT_EJEMPLARES), 0) AS CORREO,
  (Select COALESCE(SUM(s.CANT_EJEMPLARES), 0) AS cant_reserva
  From SUSCRIPCIONES s
  Where (s.TIPO_SCIONES = 'PAPEL' or s.TIPO_SCIONES = 'PAPEL E INTERNET')
  and s.ESTADO_SCIONES = 'A'
  and '2013/06/08' BETWEEN s.f_inic_sciones AND s.f_fin_sciones
  and s.cod_sucursal = 1
  and s.forma_envio = 'RETIRA') AS RETIRA,

  (Select COALESCE(SUM(s.CANT_EJEMPLARES), 0) AS cant_reserva
  From SUSCRIPCIONES s
  Where (s.TIPO_SCIONES = 'PAPEL' or s.TIPO_SCIONES = 'PAPEL E INTERNET')
  and s.ESTADO_SCIONES = 'A'
  and '2013/06/08' BETWEEN s.f_inic_sciones AND s.f_fin_sciones
  and s.cod_sucursal = 1
  and s.forma_envio = 'ESTAFETA') AS ESTAFETA

From SUSCRIPCIONES s
Where (s.TIPO_SCIONES = 'PAPEL' or s.TIPO_SCIONES = 'PAPEL E INTERNET')
and s.ESTADO_SCIONES = 'A'
and '2013/06/08' BETWEEN s.f_inic_sciones AND s.f_fin_sciones
and s.cod_sucursal = 1
and s.forma_envio = 'CORREO'
Group by s.forma_envio

Está medio rebuscado, pero cuando alguna de las formas de envío no tiene ejemplares muestra un null, que lo puedo interpretar como "cero"
En lugar de hacer una fila por cada forma de envío, hice una columna (esto no es tan dramático, porque las formas de envío no han cambiado en años)
__________________
Uno es responsable de lo que hace y de lo que omite hacer.
Responder Con Cita