Search Postgresql Archives

Replace NULL values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/

        _______________________________________ 




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux