Comparing PostgreSQL JSON Values
Written
- SQL
- When comparing a JSON value to a non-JSON value, the easiest way is to use the text operators and coalesce.
coalesce(a->>'value', '0')::int > 10
- This way, if the
coalesce
works whether the value isnull
ornull::jsonb
.