Hi list,
I have a table where multiple values are stored in a delimited string
field. Values look like:
Joe
Joe,Frank,John
John,Frank
Frank
Joe,Frank
John
I need to generate aggregate results like:
Joe: 3
Frank: 4
John: 3
The table design in this case is fixed so and this is what I've tried so
far:
SELECT count(theAnswer), theAnswer
FROM (SELECT unnest(string_to_array(answer, ',')) AS theAnswer
FROM Answers) AS theAnswer
GROUP BY theAnswer
This seems to work - any gotchas I might be overlooking or a better way
of finding the totals?
Thanks,
Brian