I have data I have collect from a form. And have "pivoted" the data so it looks like this:
COUNTY | denver | seattle | new_york | dallas | san fran
-----------+---------+-----------+----------+----------+---------
ada | 3 | 14 | 0 | 0 | 0
slc | 10 | 0 | 0 | 0 | 9
canyon | 0 | 5 | 0 | 0 | 0
washington | 0 | 0 | 11 | 0 | 0
bonner | 0 | 0 | 0 | 2 | 0
(This was accomplished using case statements, crosstab is not allowed in the environment I am using: cartodb)
I now need a column that list the CITY
with the max value. For example:
COUNTY | CITY | denver | seattle | new_york | dallas | san fran
-----------+----------+---------+-----------+----------+----------+---------
ada | seattle | 3 | 14 | 0 | 0 | 0
slc | denver | 10 | 0 | 0 | 0 | 9
canyon | seattle | 0 | 5 | 0 | 0 | 0
washington | new_york | 0 | 0 | 11 | 0 | 0
bonner | dallas | 0 | 0 | 0 | 2 | 0