Hi,
It depends on the type value from the left join of tbl5 to determine which table needs to be joined. The syntax I have keeps generating an error from the case statement, but I am unsure why. Could you please assist me with this syntax
left join (select distinct tie,doc,order,type from mytb5) tbl5 ON cis.tie = ca.tie and tie.doc = ca.doc
left join
case
when tbl5.type =10 then mytb1 tbl ON tb1.order = ca.order
when tbl5.type =50 then mytb2 tb2 ON wh.order = ca.order
Since you're doing LEFT joins, you don't need a CASE. The "type = " condition in the JOIN will make sure you only get a match is one is appropriate for the type value in the tbl5 row.