I have an array column containing information like
{a,b,c,a}
{a,b,a,b}
{b,a,a,b}
I want to run unnest on this array column, get the occurence of of each character.
a 2
b 1
c 1
a 2
b 2
b 2
a 2
I run the following query which works when considered for one row:
SELECT i, count(*) AS count
FROM unnest(array::text[]) i
GROUP BY i
ORDER BY i;