Please take this survey to help us learn more about how you use third party tools. Your input is greatly appreciated!

pivot or get dummies ?

I am trying to get from
ID Product
A hat
A gloves
B shoes
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?


Leave a Comment

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

Can't find what you're looking for? Search the Vertica Documentation, Knowledge Base, or Blog for more information.