The Vertica Forum recently got a makeover! Let us know what you think by filling out this short, anonymous survey.
Please take this survey to help us learn more about how you use third party tools. Your input is greatly appreciated!
Pivot with non unique IDs
I have data that looks like
And I want to get to
I looked at https://forum.vertica.com/discussion/238733/how-do-i-pivot-in-vertica but still stuck. Can anyone help?
The query should be this:
SELECT id , (MAX(CASE fruit WHEN 'Pear' THEN counter END) IS NOT NULL) AS Pear , (MAX(CASE fruit WHEN 'Orange' THEN counter END) IS NOT NULL) AS Orange , (MAX(CASE fruit WHEN 'Apple' THEN counter END) IS NOT NULL) AS Apple FROM w_counter GROUP BY id -- out id|Pear |Orange|Apple -- out 1|true |true |false -- out 2|true |false |true1