Skip site navigation (1) Skip section navigation (2)

adding fields containing NULL values

From: Werner Modenbach <modenbach(at)alc(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: adding fields containing NULL values
Date: 2000-05-29 11:58:31
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
Hi all!

Let's say I have a table like:

employee  date        sallary   extras
Name1     01-31-1999  5000.00   NULL
Name1     02-29-1999  5000.00   500.00
Name1     03-31-1999  5000.00   NULL

I would like to get something like:

employee  date        total
Name1     01-31-1999  5000.00
Name1     02-29-1999  5500.00
Name1     03-31-1999  5000.00

Umfortunately 'select employee,date,sallary+extras as total' doesn't give the
desired result because 'somevalue + NULL' is considered to be NULL. 
Is there any solution for my (small) problem?

- Werner -

BTW: I'm running PostgreSQL V 6.5.1

Werner Modenbach		 modenbach(at)alc(dot)de
ALC Computertechnik GmbH


pgsql-sql by date

Next:From: Grant FinnemoreDate: 2000-05-29 13:43:07
Subject: Re: adding fields containing NULL values
Previous:From: Grant FinnemoreDate: 2000-05-29 09:50:10
Subject: Re: Rollback & Nextval fails

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group