From: | Stefan Schwarzer <stefan(dot)schwarzer(at)grid(dot)unep(dot)ch> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Replace NULL values |
Date: | 2006-09-07 05:45:19 |
Message-ID: | 317DE199-30AB-491B-A539-B026FF63581D@grid.unep.ch |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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/
_______________________________________
From | Date | Subject | |
---|---|---|---|
Next Message | C.Strobl | 2006-09-07 06:45:41 | postgres and emacs on windows os |
Previous Message | Joshua D. Drake | 2006-09-07 04:41:32 | Re: Majordomo drops multi-line Subject: |