| From: | Michael Glaesemann <grzm(at)myrealbox(dot)com> | 
|---|---|
| To: | pgsql-novice(at)postgresql(dot)org | 
| Subject: | + operator with a possible NULL operand | 
| Date: | 2003-05-29 05:58:05 | 
| Message-ID: | 84210D83-919A-11D7-BEFD-0005029FC1A7@myrealbox.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-novice | 
I'm getting my feet wet using PostgreSQL and have run in to a bit of a 
snag with using the + operator.
I want to create a table that has a third column that is the sum of the 
values of two other columns. In essence:
SELECT	a.qty AS aa,
		b.qty AS bb,
		a.qty + b.qty AS cc
	FROM ...
The FROM is a subquery that includes a number of full joins, so there 
are occasions when a.qty or b.qty are NULL.
The select statement seems to work just fine, except that where a.qty 
or b.qty are NULL, cc is also NULL. (I can see how this might not work, 
PostgreSQL protesting, "Okay, you want me to add this and ... and ... 
and what, exactly?" But maybe I've misconceived what the problem is.)
I've googled for "postgresql mathematical operator null argument", 
taken a gander at the html help files included with the PostgreSQL 
installation and through Practical PostgreSQL in the sections on 
mathematical operators, but didn't find anything that mentions this. 
I'm probably not looking in the right places.
If someone point me in the direction I should look, I'd really 
appreciate it.
Thanks for your time!
Michael Glaesemann
grzm myrealbox com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2003-05-29 06:38:31 | Re: + operator with a possible NULL operand | 
| Previous Message | Nabil Sayegh | 2003-05-28 19:47:10 | Re: Inserting data of two other tables [Now deleting ...] |