So I want to aggregate groups of points that share the same location and then count the number of each class that belongs to the point.
My aggregation query is as follows:
create table mytable2 as
select count(*) as rows, location, string_agg(distinct class, ', ' order by class)
from mytable
group by location
The outcome of this gives me a row of for example
(16, 'Wakanda', 'warrior priest tank')
How do I aggregate it to show instead
(16, 'Wakanda', '10 warrior 5 priest 1 tank')