Sum by category
Posted: Mon Oct 05, 2015 9:50 pm
Hello. I have a Vertica table that looks something like this:
What I am attempting to do is summarize this table so that it looks like this:
I come from a SAS background, and doing something like this is extraordinarily easy with a TRANSPOSE statement. Is there a Vertica SQL equivalent to TRANSPOSE?
My assumption has been to employ the PARTITION/OVER statements, but I've run into a brick wall chasing that particular squirrel.
Thanks in advance!
Code: Select all
Company Product Revenue
A Widgets 15
A Cat food 5
B Sneakers 50
B Widgets 12
B Cat food 95
B Cat food 5
Code: Select all
Company Widgets_rev Cat_food_rev Sneakers_rev
A 15 5 (null)
B 12 100 50
My assumption has been to employ the PARTITION/OVER statements, but I've run into a brick wall chasing that particular squirrel.
Thanks in advance!