How to convert PostgreSQL 9.4's jsonb type to float

前端 未结 7 634
误落风尘
误落风尘 2020-12-14 14:36

I\'m trying the following query:

SELECT (json_data->\'position\'->\'lat\') + 1.0 AS lat FROM updates LIMIT 5;

(The +1.0 is just there

7条回答
  •  醉梦人生
    2020-12-14 14:48

    You must to cast the json value to text and then to float.

    Try this:

    (json_data #>> '{field}')::float
    

提交回复
热议问题