Replace NULL values - Mailing list pgsql-general

From Stefan Schwarzer
Subject Replace NULL values
Date
Msg-id 317DE199-30AB-491B-A539-B026FF63581D@grid.unep.ch
Whole thread Raw
Responses Re: Replace NULL values  (Martijn van Oosterhout <kleptog@svana.org>)
List 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 by date:

Previous
From: "Joshua D. Drake"
Date:
Subject: Re: Majordomo drops multi-line Subject:
Next
From:
Date:
Subject: postgres and emacs on windows os