Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Bases de datos > Firebird e Interbase
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 11-11-2004
jbetancurt jbetancurt is offline
Registrado
 
Registrado: nov 2004
Posts: 6
Poder: 0
jbetancurt Va por buen camino
Como valido un null??

hola... otra vez yo

Les hago una pregunta... resulta que en un query estoy sumando el mismo campo de la siguiente forma (Firebird 1.5)

Código SQL [-]
 select distinct
(select sum(a.VALOR) from T_ABONOS a where a.TIPO = 1) -
(select sum(a.VALOR) from T_ABONOS a where a.TIPO = 2) from T_ABONOS

pero cuando uno de los dos resultados es null necesito tomar este como un 0 y asi al efectuar la operacion tenga resultados positivos o negativos, pero en el momento solo consigo un Null... que debo hacer????
Responder Con Cita
  #2  
Antiguo 11-11-2004
Avatar de Investment
Investment Investment is offline
Miembro
 
Registrado: may 2003
Posts: 378
Poder: 21
Investment Va por buen camino
En SQL SERVER puedes hacer lo siguiente:

Código:
select distinct
(select sum(ISNULL(a.VALOR,0)) from T_ABONOS a where a.TIPO = 1) -
(select sum(ISNULL(a.VALOR,0) from T_ABONOS a where a.TIPO = 2) from T_ABONOS
No se si esto funcionará contra Firebird 1.5
__________________
Saludos,
Peter Investment
Responder Con Cita
  #3  
Antiguo 11-11-2004
jbetancurt jbetancurt is offline
Registrado
 
Registrado: nov 2004
Posts: 6
Poder: 0
jbetancurt Va por buen camino
Gracias por la pista...

listo ya encontre como... no era con 'ISNULL(a.VALOR,0))' pero era la ecencia
si alguien mas le sirve es de la siguiente forma......
Código SQL [-]
 
select distinct
(select COALESCE(sum(a.VALOR),0) from T_ABONOS awhere a.TIPO = 1) -
(select COALESCE(sum(a.VALOR),0) from T_ABONOS awhere a.TIPO = 2)from T_ABONOS

y no

Código SQL [-]
 
select distinct
(select sum(a.VALOR) from T_ABONOS awhere a.TIPO = 1) -
(select sum(a.VALOR) from T_ABONOS awhere a.TIPO = 2)from T_ABONOS
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 22:53:16.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi