Hi all—
I have to queries I need to combine with a left join and I am having trouble figuring out the syntax. I need to join the first query with a query that contains Unions. The queries need to by joined onFile_NBR which is contained in vw_SBC_Employee_Info,vw_ADPFile and SBC_Best_Scores.
Query 1
SELECT
e1.File_NBR,
e1.Division,
e1.Department,
e1.Program,
e1.UNIT,
(e6.Mngr_FName+' '+ e6.Mngr_LName)AS President,
(e5.Mngr_FName+' '+ e5.Mngr_LName)AS VP,
(e4.Mngr_FName+' '+ e4.Mngr_LName)AS AVP,
(e3.Mngr_FName+' '+ e3.Mngr_LName)AS Director,
(e2.Mngr_FName+' '+ e2.Mngr_LName)AS AD,
(e1.Mngr_FName +' '+ e1.Mngr_LName)AS Supervisor,
(e1.First_Name+' '+ e1.Last_Name)AS Case_Planner
FROM
[New_EEs].[dbo].[vw_SBC_Employee_Info] e1
JOIN
[New_EEs].[dbo].[vw_ADPFile] e2
on e1.Supervisor_Position_NBR=e2.POSITION_NBR
join
[New_EEs].[dbo].[vw_ADPFile] e3
on e2.Supervisor_Position_NBR=e3.POSITION_NBR
left join
[New_EEs].[dbo].[vw_ADPFile] e4
on e3.Supervisor_Position_NBR=e4.POSITION_NBR
leftjoin
[New_EEs].[dbo].[vw_ADPFile] e5
on e4.Supervisor_Position_NBR=e5.POSITION_NBR
left join
[New_EEs].[dbo].[vw_ADPFile] e6
on e5.Supervisor_Position_NBR=e6.POSITION_NBR
orderby e1.UNIT;
Query 2
SELECT
'Skill Rating'as Assessment_Type,
bs.File_NBRas ID,
bs.Skill_NBR,
bs.Best_Scoreas Score,
bs.Assesment_RND
FROM
[New_EEs].[dbo].[SBC_Best_Scores] bs
union
SELECT
sd.Assessment_Type,
sd.EXAMINEE_NBRas ID,
Skill_NBR,
sd.SCORE,
sd.SBC_RND
FROM
[New_EEs].[dbo].[vw_SBC_Score_Details]sd
orderby ID,Assessment_Type;
Again I’m finding this tricky any assistance will be greatly aperciated!
Thanks-