minglelinch
asked on
A Pivot question
How can I use the Pivot table to change the following data layout
Type Text Value
----------------------
Com abcd 1
Com efgh 2
Net wxyz 3
Net abcd 1
into this layout?
Text Com Net
------------------------
abcd 1 1
efgh 2 0
wxyz 0 3
Thanks.
Type Text Value
----------------------
Com abcd 1
Com efgh 2
Net wxyz 3
Net abcd 1
into this layout?
Text Com Net
------------------------
abcd 1 1
efgh 2 0
wxyz 0 3
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:) it is a very nice answer.
My antique view though is that a good old fashioned way may still be easier.
My antique view though is that a good old fashioned way may still be easier.
select
Text
, isnull(max(case when type = 'Com' then value end),0) as Com
, isnull(max(case when type = 'Net' then value end),0) as Net
from your_table
group by
Text
but I guess that's because I'm used to it. We used to call this pivoting before the 'pivot feature' arrived on the scene.
ASKER
Excellent! Thanks for the simple solution!
ASKER