I have the following four tables with the following structures
Table A
ColA1 ColA2 ColA3 ColA4 ColA5
-----------------------------------------
AA 100 CC DD EE
Table B
ColB1 ColB2 ColB3 ColB4 ColB5
-------------------------------------------
AA 100 40452 A9 CDE
when these two tables
were joined like the following:
Select colA1,ColA2, ColA3, ColA4, ColB3,ColB4, ColB5
from table A
Left outer join
(select ColB3, ColB4, ColB5
from table B
where colB3 = (select max(colB3) from table B
)
on (colA1 = colB1 and ColA2 = col B2);
Now i have to join the next table C
with table B
Table C structure is
ColD1 ColD2 ColD3
--------------------------------
Desc1 A9 Executive
Desc1 A7 Engineer
I have the common column such as ColD2 and colB4
to get the Col D3
how do i join the existing query + join between
table b and table c?
Not tested but it would be something like given below
SELECT colA1,ColA2, ColA3, ColA4, ColB3,ColB4, ColB5,ColD3
FROM table A
LEFT OUTER JOIN
(SELECT ColB3, ColB4, ColB5
FROM table B
WHERE colB3 = (SELECT MAX(colB3) FROM table B
)
ON (colA1 = colB1 AND ColA2 = col B2)
LEFT OUTER JOIN TABLE C
ON (colB4=colD2);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.