2 votes
Accepted

COALESCE with cast

NULLIF, like you already found: SELECT NULLIF(raw_record->>'ObjectCount','')::int ... .. to replace the empty string with NULL. Strictly speaking, your question asks for more: Is there a ...
Erwin Brandstetter's user avatar
2 votes

COALESCE with cast

I was on the right track but the wrong train. Here's what ended up working: select COALESCE(NULLIF(raw_record->>'ObjectCount',''),0)::int from resources where record_id = '274015000000'
user101289's user avatar
1 vote

When to use NULL and when to use an empty string?

Generally speaking, a database NULL should be thought of as "This Is Unknown". In the case of something like a Date of Birth, or a Height In Centimeters column, it makes perfect sense to ...
Slartibartfast's user avatar
1 vote

When to use NULL and when to use an empty string?

If we talk about theory, then the Codd's rules say that RDBMS must treat NULL values in a special way. How exactly that is used is up to database architects, depending on actual domain - task - ...
noonex's user avatar
  • 151

Only top scored, non community-wiki answers of a minimum length are eligible