Ver Mensaje Individual
  #1  
Antiguo 21-12-2005
Avatar de AGAG4
AGAG4 AGAG4 is offline
Miembro
 
Registrado: ago 2004
Ubicación: Los Mochis, Sinaloa, México
Posts: 1.420
Reputación: 21
AGAG4 Va por buen camino
Como Validar Filas en Select?

Hago 4 consultas unidas con UNION.
Código SQL [-]
//Ventas de Contado
select SUM(IMPORFAC) from facturas
where
credcon=1 and
fechafac>='01.04.2005' and
fechafac<='30.04.2005'
UNION
 
//Ventas de Credito
select SUM(IMPORFAC) from facturas
where
credcon=2 and
fechafac>='01.04.2005' and
fechafac<='30.04.2005'
UNION
 
//Notas de Crédito
select SUM(IMPMOV) from climovim
where
(tipomov='NX' or tipomov='NM') and
fechamov>='01.04.2005' and
fechamov<='30.04.2005'
UNION
//Devoluciones
select SUM(IMPORTE) from invmovim
where
(tipomov='DX' or tipomov='DM') and
fechamov>='01.04.2005' and
fechamov<='30.04.2005'
En estas sentencias me muestra 4 FILAS:
1,200
2,200
500
200

Estan perfectas las consultas, pero tengo el problema que si no hay ventas de crédito me pone:
1,200
500
200

No puedo diferenciar entre las filas si no hay Ventas de Crédito o bien no hubiese Notas de Crédito, me gustaría que en vez de que no muestre nada me muestre un CERO asi yo saber de que no hubo Ventas de Crédito ejemplo:
1,200
0
500
200

Ya probe con
Código SQL [-]
 
....
select SUM(case when (IMPORTE=0 or IMPORTE is Null ) then 0.00 end) from tinv_invmovim
....
Pero de todas formas me devuelve 3 filas, no me muestra en la FILA un CERO para identificar.

Agradezco cualquier sugerencia.

Última edición por AGAG4 fecha: 21-12-2005 a las 17:26:13. Razón: Corrección
Responder Con Cita