Skip to content
Advertisement

SQL Row Data to Column Data in Join

Trying to wrap my tiny brain around how to write this query and I am at a loss:

Current:

TABLE

How I would like it to look:

enter image description here

If someone can point me to a function that could help me with this, it would be much appreciated. I already tried using:

max(case when ....) and pivot()

which I found in other articles, but could not get them to work with my JOIN:

Any help would be MUCH appreciated to at least get me pointed in the right direction…

Advertisement

Answer

This should do it. If you need the number of roles to be flexible it would be more complicated. You would need to create your sql in a string and use exec sp_executesql to execute it

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement