Re: select null + 0 question - Mailing list pgsql-general

From
Subject Re: select null + 0 question
Date
Msg-id 64897.216.238.112.88.1058185494.squirrel@$HOSTNAME
Whole thread Raw
In response to Re: select null + 0 question  (Mike Mascari <mascarm@mascari.com>)
List 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




pgsql-general by date:

Previous
From: Jason Tishler
Date:
Subject: Re: [CYGWIN] pg_restore very slow
Next
From: nolan@celery.tssi.com
Date:
Subject: Re: Auto Starting Postgresql Under Mandrake 9.1 ??