This works. Is the recommended approach? Or maybe ...
# sql
j
This works. Is the recommended approach? Or maybe you destructure x,y in the as part idk
Copy code
select regr_slope((val->>'val')::numeric,(val->>'open_time')::numeric) from jsonb_array_elements('[
  { "open_time": 161, "val": 15 },
  { "open_time": 162, "val": 9 },
  { "open_time": 163, "val": 12 },
  { "open_time": 164, "val": 7 },
  { "open_time": 165, "val": 6 },
  { "open_time": 166, "val": 9 },
  { "open_time": 167, "val": 8 }
]') as val;