AGAG4
21-12-2005, 17:11:06
Hago 4 consultas unidas con UNION.
//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
....
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.
//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
....
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.