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 ...
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'
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 ...
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 - ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
empty-string × 14null × 7
sql-server × 3
postgresql × 3
mysql × 2
sql-server-2008 × 2
stored-procedures × 2
oracle × 1
performance × 1
database-design × 1
sql-server-2012 × 1
sql-server-2008-r2 × 1
t-sql × 1
join × 1
sql-server-2005 × 1
sqlite × 1
datatypes × 1
table × 1
best-practices × 1
array × 1
odbc × 1
where × 1
cast × 1
default-value × 1
uuid × 1