M
M
McMike2016-11-11 08:26:39
PostgreSQL
McMike, 2016-11-11 08:26:39

How to convert empty string to 0 in postgres?

The request has a piece cast(X as float)
Sometimes X can be an empty string, then it crashes with an error. What to use to convert '' to 0?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2016-11-11
@McMike

The construct COALESCE(NULLIF(X, ''), 0)will return 0 if X is NULL or an empty string.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question