BUG #4057: SUM returns NULL when given no rows

From: "Reginald Drake" <reggie(dot)drake(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #4057: SUM returns NULL when given no rows
Date: 2008-03-25 11:01:44
Message-ID: 200803251101.m2PB1imu036236@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 4057
Logged by: Reginald Drake
Email address: reggie(dot)drake(at)gmail(dot)com
PostgreSQL version: 8.2.7
Operating system: Ubuntu linux
Description: SUM returns NULL when given no rows
Details:

Doing something like "SELECT SUM(some_integer_column) FROM some_table WHERE
FALSE" gives me NULL, where I would expect 0. Since COUNT does give a
meaningful value when applied to zero columns, maybe SUM should do the same.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Sergey Burladyan 2008-03-25 11:13:07 can't delete record from second table in rules of view with join select
Previous Message Eugen.Konkov 2008-03-25 10:51:11 BUG: PG do not use index