Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/02/2012, 11:11
carnero
 
Fecha de Ingreso: noviembre-2009
Mensajes: 315
Antigüedad: 14 años, 5 meses
Puntos: 0
Exclamación consulta not exists no arroja valores

tengo la siguiente consulta y los 2 select por separado arrojan los datos correspondientes, pero al comparar con el not exists no me da valores.

Código SQL:
Ver original
  1. SELECT  cwtauxi.codaux, cwtauxi.nomaux AS NOMBRE,
  2. cwtauxi.rutaux AS RUT, cwtauxi.diraux AS DIRECCION, cwtauxi.fonaux1 ,
  3. cwtciud.ciudes AS CIUDAD, cwtvend.VenDes AS VENDEDOR, cwtzona.ZonDES AS ZONA
  4.  
  5. FROM ((((cwtauxi
  6.  
  7. INNER JOIN cwtcvcl ON cwtcvcl.codaux = CWTauxi.codaux)
  8.  
  9. INNER JOIN cwtvend ON cwtvend.VenCod = cwtcvcl.CodVen)
  10.  
  11. INNER JOIN cwtciud ON cwtciud.CiuCod = cwtauxi.CiuAux)
  12.  
  13. LEFT JOIN  cwtzona ON cwtzona.ZonCod = cwtcvcl.CodZon)
  14.  
  15.  
  16. WHERE
  17.  
  18. NOT EXISTS
  19.  
  20.  (SELECT iw_gsaen.codaux
  21.  
  22. FROM  (((IW_GSAEN
  23.  
  24. INNER JOIN iw_gmovi ON iw_gmovi.NroInt = iw_gsaen.NroInt)
  25.  
  26. INNER JOIN iw_tprod ON iw_tprod.CodProd = iw_gmovi.CodProd)
  27.  
  28. INNER JOIN iw_tgrupo ON iw_tgrupo.CodGrupo = iw_tprod.CodGrupo )
  29.  
  30.  
  31. WHERE iw_gmovi.tipo = 'F'  AND iw_gsaen.Estado = 'V'  
  32.  
  33. AND iw_gsaen.fecha BETWEEN #22/11/2011# AND #22/11/2011#)

tambien la probe asi.

Código SQL:
Ver original
  1. SELECT *
  2. FROM  cwtauxi
  3. WHERE
  4. NOT EXISTS
  5.  
  6.  (SELECT iw_gsaen.codaux
  7.  
  8. FROM  IW_GSAEN WHERE iw_gsaen.fecha BETWEEN #22/11/2011# AND #22/11/2011#)

y tampoco resulta.

muchas gracias por la ayuda!
.................................................. .................................................. .................................................. ......................

ME FALTABA: and iw_gsaen.codaux = cwtauxi.codaux

AHORA EL PROBLEMA ES QUE SE DEMORA MUUUUUUUUUUUUUUCHO, COMO LO PUEDO OPTIMIZAR?? GRACIAS

Última edición por carnero; 09/02/2012 a las 12:05