swaggrK
asked on
Changing SQL Query Output from Columns to Row Headers
I have a table that contains actor assignments that I need to display as column headers and count how many of those assignments an actor has participated in,
This is my sample query:
This is the output of my sample query.
I would like for my output to look like this:
This is my sample query:
SELECT TOP 5
a_ActorIdentifierName as Actor
,a_AssignmentsIdName as Assignments
,a_partsandincrementsId as AssignmentsID
FROM a_partsandincrements
WHERE a_ActorID IN ('11122,'22233')
This is the output of my sample query.
Actor Assignments AssignmentsID
Arr, Andrew Full Swing 23
Arr, Andrew Media Fee 32
Arr, Andrew Extra Risk 43
Arr, Andrew Understudy Principal 15
Arr, Andrew Understudy Principal 18
Smith, Steve Full Swing 31
Smith, Steve Dance Captain 49
I would like for my output to look like this:
Actor Full Swing Media Fee Extra Risk Understudy Principal Dance Captain
Arr, Andrew 1 1 1 2 0
Smith, Steve 1 0 0 0 1
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@Mark Bullock
Your suggestion works but it outputs a row for every actor and when I add DISTINCT, it only outputs one actor.
How can I get the query to output a single row for every actor?
Your suggestion works but it outputs a row for every actor and when I add DISTINCT, it only outputs one actor.
How can I get the query to output a single row for every actor?
ASKER
Open in new window