I'm still trying to wrap my head around Pivot and Unpivot and the like, but I can't for the life of me figure out how to do something in T-SQL that I'm sure is crazy simple. So I'm hoping some of you SSMS/T-SQL gurus can help me out here.
What I need to do is to turn something like this:
Salesman Number of Clients # of Sales Last Year # of Projected Sales
----------------------------------------------------------------------------
Rob 44 200 150
Bill 28 120 100
Thomas 60 300 320
Into something like this:
Rob Bill Thomas
Number of Clients 44 28 60
# of Sales Last Year 200 120 300
# of Projected Sales 150 100 320
All of the pivot and unpivot examples I've seen seem to only work if you're aggregating values with SUM and the like. I don't need to aggregate anything. I just need to shift one of the columns into column headers, basically.
I have seen some other examples here. But they all either use aggregation or single columns of info. None does the same thing that I'm looking to do here. I just need some simple code to do what should be a very simple task. If TSQL simply can't do this without some complicated kludgy work-around, then a simple "TSQL can't do that" will work too.