Back to Playground Home

Sum values extracted from a JSON field

select json_extract_scalar(json_field, '$.details.collaborator', 'STRING') AS collaborator,
       sum(json_extract_scalar(json_field, '$.details.score', 'INT')) AS score,
       count(*)
from users 
group by collaborator
ORDER BY count(*) DESC
limit 10