Reputation: 742
I have a table with 4 columns name
, gender
, age
and hair_color
.
hair_color
has 3 options Blond
, Black
and Brown
.
Can I use the pivot
command to generate a table with columns name
, gender
, age
, blond
, black
and brown
with the same number of rows.
Upvotes: 0
Views: 44
Reputation: 36
select *
from FOURCOLUMNTABLE
pivot (
count(HAIR_COLOR) as HC
for HAIR_COLOR in ('Blond','Black','Brown')
)
Upvotes: 1