Reputation:
for a table like this
id|col
1 |a
2 |b
3 |a
I would like to get an array of just col elements ordered by how often they appear in the table. how can this be done?
Upvotes: 0
Views: 34
Reputation: 48207
SELECT ARRAY(SELECT col
FROM yourTable
GROUP BY col
ORDER BY COUNT(*) );
Upvotes: 2