Link to home
Start Free TrialLog in
Avatar of minglelinch
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.
ASKER CERTIFIED SOLUTION
Avatar of coreconcepts
coreconcepts
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of minglelinch
minglelinch

ASKER

Nice answer. Thank you.
Avatar of PortletPaul
:) it is a very nice answer.

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

Open in new window

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.
Excellent!  Thanks for the simple solution!