I have PostgreSQL table with some columns group by Area column. I want to do aggregation by the column Application and then calculate number of each item.
I tried
SELECT app.area, array_agg(app.application)
FROM applications as app GROUP BY app.area
and have got the list of applications:
Item1,Item2,Item1,Item3,Item1
How can I get next:
Item1: 3
Item2: 1
Item3: 1
You can use the SQL COUNT() function.
You can get some info about it and some examples here: http://www.w3schools.com/sql/sql_func_count.asp