select null + 0 question

From: Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>
To: pgsql-general(at)postgresql(dot)org
Subject: select null + 0 question
Date: 2003-07-14 05:42:26
Message-ID: 3F1242C2.8080802@mega-bucks.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Why is it that "select null + 1" gives null but "select sum(a) from
table" where there are null entries returns an integer?

Shouldn't the sum() and "+" operators behave the same?

TAL=# select null + 0;
?column?
----------

(1 row)

TAL=# select * from a;
a
---

1
(3 rows)

TAL=# select sum(a) from a;
sum
-----
1
(1 row)

Thanks,

Jean-Christian Imbeault

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ron Johnson 2003-07-14 05:54:55 Re: Is SQL silly as an RDBMS<->app interface?
Previous Message Jim Rosenberg 2003-07-14 02:48:55 Re: OS X installation with readline support