parpaa
asked on
SQL Pivot Table
Hi,
I am trying to run the following resultset
Year Quarter Score Name
2012 1 45 ABC
2012 2 22 ABC
2012 3 32 ABC
2012 4 45 ABC
2011 1 45 ABC
2011 2 22 ABC
2011 3 32 ABC
2011 4 45 ABC
into this below format.
2012 2012 2012 2012 2011 2011 2011 2011
Name 1 2 3 4 1 2 3 4
ABC 45 22 32 45 45 22 32 45
I believe this can be done using Pivot, not sure how to get this with two headers (Year +Quarter).
Any thoughts is appreciated
I am trying to run the following resultset
Year Quarter Score Name
2012 1 45 ABC
2012 2 22 ABC
2012 3 32 ABC
2012 4 45 ABC
2011 1 45 ABC
2011 2 22 ABC
2011 3 32 ABC
2011 4 45 ABC
into this below format.
2012 2012 2012 2012 2011 2011 2011 2011
Name 1 2 3 4 1 2 3 4
ABC 45 22 32 45 45 22 32 45
I believe this can be done using Pivot, not sure how to get this with two headers (Year +Quarter).
Any thoughts is appreciated
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks guys,
Dtodd - Your solution served my purpose
Indeed it was great post on Dynamic Pivot SQL, thanks again
Dtodd - Your solution served my purpose
Indeed it was great post on Dynamic Pivot SQL, thanks again
ASKER
Name 2012 Q1 2012 Q2 2012 Q3 2012 Q4 2011 Q1 2011 Q2 2011 Q3 2011 Q4
ABC 45 22 32 45 45 22 32 45