Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > SQL
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 24-12-2009
toni.vi toni.vi is offline
Miembro
 
Registrado: may 2003
Ubicación: Sant Fost(Barcelona)
Posts: 102
Poder: 21
toni.vi Va por buen camino
Comparar con Null

Tengo la siguiente consulta:
Código SQL [-]
Select H.ID_ARTICULO,  H.NUMERO
, (Select SUM(H1.CANTIDAD) From FVHISARTI H1
   where H1.ID_ARTICULO = H.ID_ARTICULO and H1.NUMERO = H.NUMERO and H1.clave = '51') as Ventas
from FVHISARTI H
WHERE H.ID_ARTICULO = 100
group by H.ID_ARTICULO, H.NUMERO
Lo que ocurre es en el campo NUMERO tengo algunos registros que su valor es nulo y no me los saca.
No hace la comparativa "and H1.NUMERO = H.NUMERO"
y el resultado es 0.
¿Como lo puedo solucionar?
Responder Con Cita
  #2  
Antiguo 24-12-2009
Avatar de droguerman
droguerman droguerman is offline
Miembro
 
Registrado: abr 2005
Ubicación: tierra
Posts: 999
Poder: 20
droguerman Va por buen camino
Código SQL [-]
Select H.ID_ARTICULO,  H.NUMERO
, (Select SUM(H1.CANTIDAD) From FVHISARTI H1
   where H1.ID_ARTICULO = H.ID_ARTICULO and ISNULL(H1.NUMERO,0) = ISNULL(H.NUMERO,0) and H1.clave = '51') as Ventas
from FVHISARTI H
WHERE H.ID_ARTICULO = 100
group by H.ID_ARTICULO, H.NUMERO
__________________
self.free;
Responder Con Cita
  #3  
Antiguo 24-12-2009
toni.vi toni.vi is offline
Miembro
 
Registrado: may 2003
Ubicación: Sant Fost(Barcelona)
Posts: 102
Poder: 21
toni.vi Va por buen camino
No he comentado que trabajo con FB1.5 y la funcion isnull me da error.
Function unknown.
ISNULL.
Responder Con Cita
  #4  
Antiguo 24-12-2009
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.044
Poder: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
coalesce

Código:
SELECT COALESCE(NOMBRE,'NO REGISTRADO') FROM ESTUDIANTE SWHERE CODIGO = :C'
En el ejemplo, si nombre es null, lo sustituye por "no registrado"
Responder Con Cita
  #5  
Antiguo 24-12-2009
toni.vi toni.vi is offline
Miembro
 
Registrado: may 2003
Ubicación: Sant Fost(Barcelona)
Posts: 102
Poder: 21
toni.vi Va por buen camino
Funciona,
Gracias
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

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Fecha null en sql pablomg8 SQL 3 24-09-2008 10:00:31
cambiar campo null a not null andressanchez Firebird e Interbase 8 18-09-2006 22:00:09
Null y UDF ARPE Firebird e Interbase 0 08-09-2004 10:56:20
Null y Delphi 7 buitrago Varios 2 08-12-2003 17:59:40
campo null anay Varios 1 14-11-2003 19:49:13


La franja horaria es GMT +2. Ahora son las 09:11:09.


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