From: Jason Earl <jason.earl@simplot.com>
To: Karl Raven <lcaasia@pd.jaring.my>
Cc: pgsql-sql@postgresql.org
Subject: Re: change null to 0 in SQL script
Date: 03 Jan 2002 09:20:17 -0700
Message-ID: <87itaj5rum.fsf@npa01zz001.simplot.com> (raw)
In-Reply-To: <a10ojd$1v4q$1@news.tht.net>
References: <a10ojd$1v4q$1@news.tht.net>
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 substitute a 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: jason.earl@simplot.com, lcaasia@pd.jaring.my
Subject: Re: change null to 0 in SQL script
In-Reply-To: <87itaj5rum.fsf@npa01zz001.simplot.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox