Re: select null + 0 question

From: <btober(at)seaworthysys(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Re: select null + 0 question
Date: 2003-07-14 12:24:54
Message-ID: 64897.216.238.112.88.1058185494.squirrel@$HOSTNAME
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> Jean-Christian Imbeault wrote:
>
>> 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?
> SQL92 (6.5 <set function specification>):
> 1) Case:
> a) If COUNT(*) is specified, then the result is the cardinality of T.
> b) Otherwise, ...
> So ...
> CREATE TABLE foo (value integer);
> INSERT INTO foo VALUES (NULL);
> INSERT INTO foo VALUES (3);
> Compare:
> SELECT COUNT(*) FROM foo;
> vs.
> SELECT COUNT(value) FROM foo;

Interesting. Thanks for pointing that out. I hadn't thought about the
fact that, e.g.,

SELECT count(*), count(last_name), count(middle_name) FROM person

would produce

430, 430, 186

~Berend Tober

In response to

Browse pgsql-general by date

  From Date Subject
Next Message nolan 2003-07-14 12:32:21 Re: Auto Starting Postgresql Under Mandrake 9.1 ??
Previous Message Jason Tishler 2003-07-14 12:04:50 Re: [GENERAL] pg_restore very slow