M
M
mboze2022-04-19 11:51:39
PostgreSQL
mboze, 2022-04-19 11:51:39

Postgresql how to convert empty string to "Not Submitted"?

Good afternoon! There is a selection:
select status from rezultat
It is necessary that in the status field there should be the line "Not sent" instead of an empty line, please tell me how this can be done?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Akina, 2022-04-19
@mboze

What is an "empty string", a zero-length string, or NULL? However, both cases are covered by the construction
COALESCE(NULLIF(status, ''), 'Не отправлено')
. If there can be a handful of spaces in the status - first trim.

M
Michael, 2022-04-19
@Akela_wolf

If an empty string means NULL - then COALESCE
If an empty string means "" - then CASE

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question