In SQL Server 2017, I have two SQL Tables like below:
Table1:
ProjectId ProjectScore
1 90
2 50
3 30
Table2:
ProjectId PersonName GivenScore
1 Jack 50
1 John 30
1 Mark 10
2 Jack 20
2 John 20
2 Mark 10
3 Jack 20
3 John 10
What I need is to come with a query giving me the output below:
ProjectId ProjectScore Jack John Mark
1 90 50 30 10
2 50 20 20 10
3 30 20 10
I know I need to use "PIVOT" at some point but couldn't end up with a solution. Any help would be appreciated.