在sql Query中连接表

时间:2017-06-29 17:50:12

标签: sql database oracle oracle11g

我在oracle DB中有三个表,如下所示:

Training_Calendar_hdr

<html>, <body>

Training_Employee_mapping

-----------------------------
Training_Id     Training_Name
-----------------------------
T1               Physics
T2               Chemistry
T3               Maths

Employee_Details

---------------------------
Training_Id   Employee_Id
---------------------------
T1               E001
T1               E003
T1               E007
T3               E001
T3               E010
T3               E008
T3               E011

我需要通过连接三个表来获得结果,如下所示:

---------------------------
Employee_Id    Designation
---------------------------
E001        Engineer
E002        Professor
E003        Businessman
E004        Engineer
E005        Govt. Service
E006        Unemployed
E007        Engineer
E008        Govt. Service
E009        Professor
E010        Unemployed
E011        Professor

1 个答案:

答案 0 :(得分:1)

您可以使用PIVOT条款。请看一下这篇文章:https://www.techonthenet.com/oracle/pivot.php