Tema: Joins
Ver Mensaje Individual
  #3 (permalink)  
Antiguo 05/09/2008, 12:03
9u37241c0471
 
Fecha de Ingreso: septiembre-2008
Mensajes: 3
Antigüedad: 15 años, 7 meses
Puntos: 0
Respuesta: Joins

cuando lo hice con left join fue asi

Select DA.Codigo As Defecto,
Count(DA.Codigo) As Cantidad
-- CI.Codigo_Lote
From catDefectoAparato DA
Left Outer Join catInventarioHogar IH On IH.xtDefectoAparato_Defecto_Critico = DA.Indice
Left Outer Join catCapturaInspecciones CI On CI.xkInventarioHogar_Indice = IH.xqAsociacion
Left Outer Join catLoteAsignado LA On LA.Codigo_Lote = CI.Codigo_Lote
Left Outer Join catworkflowhistory WH On WH.Folio = LA.indice
Where LA.Codigo_Lote = 'L32RNZNGROB08381' And xtProceso_Proceso = '9' And WH.xtTarea_Tarea = '44'
Group By DA.Codigo, CI.Codigo_Lote
Order By DA.Codigo--, CI.Codigo_Lote

Acabo de hacer otro query de esta manera

Select CA.Codigo, Count(IH.xtDefectoAparato_Defecto_Critico) As Cantidad --1329396
From catInventarioHogar IH
Full Outer Join catDefectoAparato CA On CA.Indice = IH.xtDefectoAparato_Defecto_Critico
Full Outer Join catCapturaInspecciones CI On CI.xkInventarioHogar_Indice = IH.xqAsociacion
Full Outer Join catLoteAsignado LA On LA.Codigo_Lote = CI.Codigo_Lote
Full Outer Join catworkflowhistory WH On WH.Folio = LA.indice
Where LA.Codigo_Lote = 'L32RNZNGROB08381' And xtProceso_Proceso = '9' And WH.xtTarea_Tarea = '44'
Group By CA.Codigo
Order By CA.Codigo

Y me arroja el siguiente resultado
Codigo Cantidad
NULL 0
01 4
10 1
61 4
63 5


Cuando quito las condiciones del where y hago la consulta sin where me da el siguiente resultado

Select CA.Codigo, Count(IH.xtDefectoAparato_Defecto_Critico) As Cantidad --1329396
From catInventarioHogar IH
Full Outer Join catDefectoAparato CA On CA.Indice = IH.xtDefectoAparato_Defecto_Critico
Full Outer Join catCapturaInspecciones CI On CI.xkInventarioHogar_Indice = IH.xqAsociacion
Full Outer Join catLoteAsignado LA On LA.Codigo_Lote = CI.Codigo_Lote
Full Outer Join catworkflowhistory WH On WH.Folio = LA.indice
Group By CA.Codigo
Order By CA.Codigo

NULL 331116
01 8163
02 194
03 48
04 172
05 160
. 86320
. 2117
. 200
. 9587
. 26562
. 3688
. 5464
. 71903
. 444395
. 140616
. 166435
. 26535
. 0
. 0
. 0
. 0
. 10599
n 11774

Que es como quiero que se muestre los resultados pero necesito meterle condiciones con un Where

Aun no doy con la solución seguire intentando si tienen alguna sugerencia se los agradecería mucho