Transposing rows to column in SQL

Viewed 28

I am trying to figure out how to obtain the following desired result from the table mentioned below:

Original Table:

P_Key  P_ID  Type   Report_ID Name
12345  1001  Admin  23645     Jack
12346  1001  Viewer 24589     Patrick
12347  1002  Admin  23478     Lily
12348  1003  Admin  24794     John
12349  1004  Admin  12785     Tim
12350  1004  Viewer 54785     Sam

Desired Result:

P_Key  P_ID  Type   Report_ID AdminName  ViewerName
12345  1001  Admin  23645     Jack       Patrick
12347  1002  Admin  23478     Lily
12348  1003  Admin  24794     John
12349  1004  Admin  12785     Tim        Sam

I will truly appreciate any help about how to get this result in SQL. Thanks

0 Answers
Related