I have a table with a column of JSON data that I want to extract information from. Specifically I just want to get the average value.
Example of what I have:
id speed_data
391982 [{"speed":1.3,"speed":1.3,"speed":1.4,"speed":1.5...
391983 [{"speed":0.9,"speed":0.8,"speed":0.8,"speed":1.0...
Example of what I want:
id speed_data
391982 1.375
391982 0.875
Any suggestions on how to get this query to work?
select t.*, avg(x.speed)
from tbl t,
json_array_elements(a->'speed') x
order by random()
limit 1