math problem

From: Vincent Stoessel <vincent(at)xaymaca(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: math problem
Date: 2002-07-25 22:12:14
Message-ID: 3D4077BE.70506@xaymaca.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello All,

I need to find a workaround for my addition problem.

I have a list of values in 3 columns derived from a left join
where the last column is the sum of the 2 on the left.

i.e.

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

cola colb total
2 3 5
2 2 4

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.

cola colb total

3
1
4

etc.

Any work around for this, do I have to use a
Pg language? I guess I could write a script in perl
to take of this for me but I would like to tap
the brains here to see it can al be done in the
SQL.
Thanks

--
Vincent Stoessel
Linux Systems Developer
vincent xaymaca.com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2002-07-25 22:23:58 Re: math problem
Previous Message Andrew Sullivan 2002-07-25 21:53:28 Re: regression test