Re: change null to 0 in SQL script

Поиск
Список
Период
Сортировка
От Jason Earl
Тема Re: change null to 0 in SQL script
Дата
Msg-id 87itaj5rum.fsf@npa01zz001.simplot.com
обсуждение исходный текст
Ответ на change null to 0 in SQL script  ("Karl Raven" <lcaasia@pd.jaring.my>)
Список pgsql-sql
I believe that you need the coalesce function.  Here's the excerpt
from the manual:
       COALESCE
       COALESCE(value[, ...])
       The COALESCE function returns the first of its arguments that       is not NULL. This is often useful to
substitutea default       value for NULL values when data is retrieved for display, for       example:
 
       SELECT COALESCE(description, short_description, '(none)') ...


Just write your query so that it looks something like this:

SELECT coalesce(value_that_may_be_null, 0) FROM your_table;

Jason


"Karl Raven" <lcaasia@pd.jaring.my> writes:

> I like to change a null value of a query to 0 in the SQL script. I
> know how to do it in MS-SQL server and MS-Access but those commands
> does not work in pg-sql.
> 
> Anyone has any ideas?
> 
> Thanks
> 
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Tibor Laszlo"
Дата:
Сообщение: Re: change null to 0 in SQL script
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: Retrieving information from System Tables