Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

278
Visualizações
Can I JOIN table on the basis of the case statement in PostgreSQL

Can I JOIN the table on the basis of the case statement in PostgreSQL. I have written the one SQL in stored procedure into that I'm passing the one flag on that basis I want to jon the table. Please see the case statement,

JOIN lease_intervals li_active
    ON ( li_active.cid = l.cid AND l.id = li_active.lease_id AND
         l.active_lease_interval_id = li_active.id )
LEFT JOIN applications a
    ON ( a.cid = li.cid AND li.lease_id = a.lease_id AND
         a.lease_interval_id = li.id )
 **CASE
            WHEN pIsFromUI = TRUE
                       THEN JOIN property_integration_databases pid ON ( pid.cid = l.cid AND pid.property_id == l.property_id )
               JOIN integration_databases id ON ( id.id = pid.integration_database_id AND id.cid = pid.cid )
       ELSE
           1
END**

Please let me know is there any alternate solution for above.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

join
lease_intervals li_active on
    li_active.cid = l.cid and l.id = li_active.lease_id and
    l.active_lease_interval_id = li_active.id 
left join
applications a on
    a.cid = li.cid and li.lease_id = a.lease_id and
    a.lease_interval_id = li.id
left join
property_integration_databases pid on
    pid.cid = l.cid and pid.property_id = l.property_id and pisfromui
left join
integration_databases id on
    id.id = pid.integration_database_id and id.cid = pid.cid and pisfromui
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda