I have a main table that I must get data from. I have a left outer join where the fields will match 40% of the time. And then I have another join where I need to match the data from table A with.
This is the SQL in pseudo code. This query won't work.
-- This is the part I want to do but doesn't work. AND H.COL3 = A.STATE????
I am working with IBM DB2.
SELECT DISTINCT
APP_NO as app_no,
A.STATE as state
...
... Fields
...
FROM
TABLE_A A
LEFT OUTER JOIN
TABLE_B HIST
ON
HIST.COL1 = A.COL1
, TABLE_C B
LEFT OUTER JOIN
TABLE_D H
ON
H.COL2 = B.COL2
-- This is the part I want to do but doesn't work.
AND
H.COL3 = A.STATE????
WHERE
A.BRANCH = 'Data'