User-1715141361 posted
Hello,
I have been going in circles with this all day. I am hoping someone has the answer to what I am doing wrong. Thanks for your time!
I have a simple answer set that I want to pivot:
Query result
WeekEndDate....EmpID.....GFName
2020-06-13 .........12345.....Joe Smith
2020-06-13..........12345......Linda Jones
I need the result to be:
WeekEndDate....EmpId......GF1..................GF2
2020-06-13.......12345.......Joe Smith.......Linda Jones
Here is what my query returns:
WeekEndDate....EmpId......GF1..................GF2
2020-06-13.......12345.........Null................ Null
My current query
SELECT
*
FROM
(
SELECT WeekEndDate, PCH.[Id]
EmpID, E.FirstName
+
' '
+ e.LastName GFName
FROM MM_Hours PCH,
CrewDetail CD, Employee E
Where E.id
= cd.GeneralForepersonId
and cd.Crewid
= PCH.Crew
and weekenddate
=
'2020-06-13'
and PCH.id
= 12345) s
PIVOT(Max(GFName)
FOR GFName
IN([GF1],
[GF2])
)
AS PivotGFS;
I am a beginner when it comes to pivot tables.
Thanks again