I'm trying to create query which performs (Table1 inner table2) left outer join (table3 inner table4). That is , I'm trying to get 2 columns. each column from 2 tables with co-relation values.
Sorry, I might be confusing, please see below SQL.
SELECT T1.COLUMN1
,T2.COLUMN1
FROM TABEL1 T1
INNER JOIN TABLE2 T2
ON T1.ID = T2.ID
LEFT OUTER JOIN
TABLE3 T3
ON T3.ID = T4.ID
AND T3.ID_VERSION = T4.ID_VERSION
AND T3.DATE = T4.DATE
WHERE T4.ID = T2.ID
AND T4.ID_VERSION = T2.ID_VERSION
AND T4.STATE = 'T'
AND T2.ID = '1991'
AND T2.ID_VERSION =
(SELECT MAX(ID_VERSION)
FROM TABLE2 T2
WHERE T2.ID = '1991')
AND T1.CODE1 = 0
AND T1.CODE2 = 552;
This is not bringing me the right result or errors out. Please help to fix this.
Note: I'm trying to join TABLE1 & TABLE 2 get coumn1 result and joining TABLE3 & TABLE4 to get column (in left outer join as sometimes it might bring no results)