Getting null values when I try to join 3 tables. How do I proceed to get the right output?
Here are the details:
I have 3 tables as below, attaching a sample screenshot for reference on how the data is present in tables.
Table1_All
Table2_Dyn
Table3
I want the values of year and category from table3 for EmpIDs from table1. There are common values between Table1 &2 in columns job and source and between Table2&3 in job and source columns, but no direct common value between 1&3.
I tried a join query something like:
select t3.year, t3.category from t1 left join t2 on t1.job1 =t2.job2 and t1.source1=t2.source2
left join t3 on t2.job2=t3.job3 and t2.source2=t3.source3
but its returning null values. I can see query is wrong as there are duplicate values as well as it returns list of values and it is not clearly specified for comparison.
Any suggestions on how to go about this please?
