Adding a null

View: New views
3 Messages — Rating Filter:   Alert me  

Adding a null

by Bob Pawley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi
 
I am trying to add two variables.
 
However one variable sometimes returns a null value which invariably gives a null answer.
 
How can I work around this??
 
Bob

Re: Adding a null

by Sam Mason :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Nov 05, 2009 at 10:13:28AM -0800, Bob Pawley wrote:
> However one variable sometimes returns a null value which invariably
> gives a null answer.
>
> How can I work around this??

What do you want it to do with the NULL value?  I'm assuming you want to
use COALESCE, something like:

  COALESCE(n,0) + COALESCE(m,0)

--
  Sam  http://samason.me.uk/

--
Sent via pgsql-general mailing list (pgsql-general@...)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: Adding a null

by Bob Pawley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Sam

Worked perfectly.

Bob


----- Original Message -----
From: "Sam Mason" <sam@...>
To: <pgsql-general@...>
Sent: Thursday, November 05, 2009 10:28 AM
Subject: Re: [GENERAL] Adding a null


> On Thu, Nov 05, 2009 at 10:13:28AM -0800, Bob Pawley wrote:
>> However one variable sometimes returns a null value which invariably
>> gives a null answer.
>>
>> How can I work around this??
>
> What do you want it to do with the NULL value?  I'm assuming you want to
> use COALESCE, something like:
>
>  COALESCE(n,0) + COALESCE(m,0)
>
> --
>  Sam  http://samason.me.uk/
>
> --
> Sent via pgsql-general mailing list (pgsql-general@...)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

--
Sent via pgsql-general mailing list (pgsql-general@...)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general