0

I've a value of jsonb which has a key that contains an int.

I'd like to insert this into a table with an int column. I get an error of ERROR: column "abr" is of type integer but expression is of type text LINE 4: values->>'abr' as abr,

select
  values->>'_filename' as _filename,
  values->>'abr' as abr
from   temp_json;

How can I select the value with a key of abr as an int?

Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286

1 Answers1

2

This works:

select
  values->>'_filename' as _filename,
  (values->>'abr')::int as abr
from   temp_json;
Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286