Replace NULL values
От | Stefan Schwarzer |
---|---|
Тема | Replace NULL values |
Дата | |
Msg-id | 317DE199-30AB-491B-A539-B026FF63581D@grid.unep.ch обсуждение исходный текст |
Ответы |
Re: Replace NULL values
|
Список | pgsql-general |
Hi there,
is there a simple way to replace NULL values in multiple columns within the SQL statement? I changed the underlaying country template of your database; so now there are a couple of NULL values when I join the stats-table with the country table. Unfortunately, my queries have always multiple (year) columns, so I can't do a kind of manual replace.
I found that the COALESCE command does something like this, but I couldn't figure out how this works.
And this solution which I found on the Net:
=> SELECT * FROM test;
a
---
1
2
3
=> SELECT a, CASE WHEN a=1 THEN 'one' WHEN a=2 THEN 'two' ELSE 'other' END FROM test;
a | case
---+-------
1 | one
2 | two
3 | other
doesn't work either, cause the titles of my columns are very varied...
Thanks for any advice,
Stefan Schwarzer
_______________________________________
Stefan Schwarzer
GIS & Data Management
UNEP/DEWA/GRID-Europe
Chemin des Anemones 11
CH - 1219 Chatelaine
Switzerland
Tel: (+41) 22.917.83.49
Fax: (+41) 22.917.80.29
Internet: http://geodata.grid.unep.ch/
_______________________________________
В списке pgsql-general по дате отправления: