I have a JSON column, named info, with these values:
{"width":"800, "height":"480"}
{"width":"800, "height":"480"}
{"width":"768, "height":"480"}
I need a SQL query to have the output in this format:
Label |Count
==============
800x480, 2
768x480, 1
Where the second value represents the count.
What I managed to do is to extract first value and the count:
select info->>'width' as label, count(info->>'width') from table_name GROUP BY 1 ORDER BY 2 DESC LIMIT 5
Which outputs:
Label |Count
==============
800, 2
768, 1