0

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?

1
  • Sample output please Commented Jun 17, 2019 at 9:05

1 Answer 1

2
SELECT ARRAY(SELECT col
             FROM yourTable
             GROUP BY col
             ORDER BY COUNT(*) );
Sign up to request clarification or add additional context in comments.

1 Comment

ORDER BY COUNT(*) DESC may be

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.