Re: Replace NULL values
От | Stefan Schwarzer |
---|---|
Тема | Re: Replace NULL values |
Дата | |
Msg-id | 02457F1F-149A-421D-BF55-FF85113B18BD@grid.unep.ch обсуждение исходный текст |
Ответ на | Re: Replace NULL values (Martijn van Oosterhout <kleptog@svana.org>) |
Ответы |
Re: Replace NULL values
Re: Replace NULL values |
Список | pgsql-general |
> On Thu, Sep 07, 2006 at 07:45:19AM +0200, Stefan Schwarzer wrote: >> 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. > > Yes, COALESCE replaces NULLs, however your examples have neither NULLs > nor use COALESCE, so I don't understand what your question is. > > Please repost with an actual example of your problem. As I said, I couldn't figure out how COALESCE would work on multiple columns (without naming them explicitly). So, say I have a table with columns for each year between 1970 and 2005. For specific countries the values might be NULL, depending if the statistical table has been updated recently (then they will have a value), or not (then they will be NULL). A sample query would thus be something like: SELECT * FROM pop_density
В списке pgsql-general по дате отправления: