0
我有一个JSON列,命名方式,使用这些值:总结JSON场9.3
{"width":"800, "height":"480"}
{"width":"800, "height":"480"}
{"width":"768, "height":"480"}
我需要一个SQL查询,在这种格式输出:
Label |Count
==============
800x480, 2
768x480, 1
在哪里第二个值表示计数。
我设法做的是首先提取值和计数:
select info->>'width' as label, count(info->>'width') from table_name GROUP BY 1 ORDER BY 2 DESC LIMIT 5
,输出:
Label |Count
==============
800, 2
768, 1