From: Josh Berkus <josh@agliodbs.com>
To: pgsql-sql@postgresql.org
Subject: Re: 7.0.3 and 7.1.3 different results?
Date: Wed, 03 Oct 2001 07:48:51 -0700
Message-ID: <web-140852@davinci.ethosmedia.com> (raw)
In-Reply-To: <web-140850@davinci.ethosmedia.com>
Joel,
> A query such as "select sum(pages) from job_documents where
> delivery_type='print'" returned 0 in version 7.0.3 if there were no
> rows
> matching the query. In 7.1.3 the result is NULL if no rows match the
> query. Why the change? Which result is "correct" according to the
> SQL
> standard?
While I wasn't aware of the change between versions, returning no rows
is correct for any aggregate except COUNT, which returns 0. Although,
now that you mention it, I'm not quite sure why that's the rule. I
mean, shouldn't COUNT return no rows, too?
Goes to show you that the SQL standard isn't even the model of perfect
consistency ....
BTW, returning no rows is somewhat different than returning NULL. WHat
you should be seeing is:
SELECT sum(id) FROM tableA WHERE field2 = 'not found';
sum
------------------
rather than
sum
------------------
NULL
-Josh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: josh@agliodbs.com
Subject: Re: 7.0.3 and 7.1.3 different results?
In-Reply-To: <web-140852@davinci.ethosmedia.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox