pivot or get dummies ?

SteeeevSteeeev Vertica Customer

I am trying to get from
ID Product
A hat
A gloves
B shoes
To
ID hat gloves shoes
A 1 1 0
B 0 0 1

I have
select ID,
MIN(DECODE(TF_NAME, 'hat', '1', '0')) AS 'hat',
MIN(DECODE(TF_NAME, 'gloves', '1', '0')) AS 'gloves',
MIN(DECODE(TF_NAME, 'shoes', '1', '0')) AS 'shoes'

But all the results are 0
Can someone tell me what I did wrong?

Answers

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file