How to convert PostgreSQL 9.4's jsonb type to float

前端 未结 7 681
误落风尘
误落风尘 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 15:11

    AFAIK there's no json->float casting in Postgres, so you could try an explicit (json_data->'position'->'lat')::text::float cast

提交回复
热议问题