How to generate a json object as key, value using postgres? How to generate a json object as key, value using postgres? postgresql postgresql

How to generate a json object as key, value using postgres?


In the inner query select countries with the number of employees in each country:

select json_object_agg(country, count)from (    select country, count(*)    from _employees    group by 1    ) s;