SQL joins

0 respostas
van_bommel

Pessoas , alterei os joins está certo?

from Sies…Emissao em
inner join Sies…ContratoSeguro csg on em.cdconseg = csg.cdconseg
inner join Sies…ItemGenerico ign on em.cdconseg = ign.cdconseg
left outer join Sies…HistItemAutoSim hias on ign.cdconseg = hias.cdconseg and ign.cditeseg = hias.cditeseg
and em.cdemi = hias.cdemi
inner join Sies…Pessoa pes on csg.cdpes = pes.cdpes
left outer join Sies…EnderecoPessoa endpes1 on csg.cdpes = endpes1.cdpes
and csg.nrseqend = endpes1.nrseqend

left outer join  Sies..EnderecoPessoa     endpes2 on  csg.cdpes	    =	endpes2.cdpes
                                                      and csg.nrseqend	= endpes2.nrseqend
    left outer join  Sies..EventoEndossoEmis  eee     on  em.cdconseg 	= eee.cdconseg
                                                      and em.cdemi	    = eee.cdemi
  
  
  
  
  
  
  
  
   where csg.tpconseg <> 2
   and csg.tpiteseg in( 0, 1 )
   and em.cdconseg = @w_cod_contrato_seguro
   and em.cdemi = @w_cod_emissao - 1
   and ign.cditeseg = @w_cod_item_seguro
--   and em.cdconseg = csg.cdconseg
 --  and em.cdconseg 	= ign.cdconseg

– and ign.cdconseg *= hias.cdconseg
– and ign.cditeseg *= hias.cditeseg
– and em.cdemi *= hias.cdemi
– and csg.cdpes = pes.cdpes
– and csg.cdpes *= endpes1.cdpes
– and csg.nrseqend *= endpes1.nrseqend
– and csg.cdpes *= endpes2.cdpes
– and csg.nrseqend *= endpes2.nrseqend
– and em.cdconseg *= eee.cdconseg
– and em.cdemi *= eee.cdemi

Criado 21 de maio de 2010
Respostas 0
Participantes 1