[英]oracle sql query joining a table with existing query
I have the following four tables with the following structures 我有以下四个具有以下结构的表
Table A 表A
ColA1 ColA2 ColA3 ColA4 ColA5
-----------------------------------------
AA 100 CC DD EE
Table B 表B
ColB1 ColB2 ColB3 ColB4 ColB5
-------------------------------------------
AA 100 40452 A9 CDE
when these two tables
were joined like the following: 当这two tables
按如下方式连接时:
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
与table B
Table C structure is 表C的结构是
ColD1 ColD2 ColD3
--------------------------------
Desc1 A9 Executive
Desc1 A7 Engineer
I have the common column such as ColD2 and colB4
to get the Col D3
我有诸如ColD2 and colB4
类的通用列来获取Col D3
how do i join the existing query + join between
table b and table c? 如何连接existing query + join between
表B和表C existing query + join between
联接?
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.