Re: math problem

From: "Roderick A(dot) Anderson" <raanders(at)acm(dot)org>
To: Vincent Stoessel <vincent(at)xaymaca(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: math problem
Date: 2002-07-25 22:24:17
Message-ID: Pine.LNX.4.33.0207251520500.19657-100000@main.cyber-office.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 25 Jul 2002, Vincent Stoessel wrote:

> now my problem comes into play when one of the
> columns is empty. I always get a NULL or empty total.
> this makes sence since NULL + 5 does not produce anything.

I think colesce is your friend

select cola, colb, sum(colesce(cola,0) + colesce(colb,0)) from ....

I've never had to use it put I've seen this situation addressed here
before. Table 9.3, pg 113 the Elephant book.

Rod
--
"Open Source Software - Sometimes you get more than you paid for..."

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Doug McNaught 2002-07-25 22:31:23 Re: regression test
Previous Message Stephan Szabo 2002-07-25 22:23:58 Re: math problem