Click here to Skip to main content
14,739,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Below is my source table

Date	   Line	 Shift 	Actual
1/2/2020	P1	  A	     88
1/2/2020	P2	  A	     88
1/2/2020	P3	  A	     88
1/2/2020	P1	  B	     99
1/2/2020	P2	  B	     99
1/2/2020	P3	  B	     99
1/2/2020	P1	  C	     77
1/2/2020	P2	  C	     77
1/2/2020	P3	  C	     77


Below is my expected result


DATE	   P1-A	  P1-B	P1-C	P2-A	P2-B	P2-C	P3-A	P3-B	P3-C
1/2/2020	88	   99	  77	  88	  99	  77	  88	  99	 77



Thanks in Advance.

What I have tried:

Since i am new to SQL SERVER i didnt understand on doing this.
Posted
Updated 20-Aug-20 7:29am

1 solution

Since you are new, here is the set of tools you need to learn to try.

Read about SQL PIVOT:
MSDN: Using PIVOT and UNPIVOT[^]
Understanding PIVOT and UNPIVOT[^]
Pivoting data in SQL Server[^]

Try out!
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900