Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

271
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!