Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

272
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda