Thread: BUG #11642: Aggregate Functions like min, max return one row in case of no rows in table
BUG #11642: Aggregate Functions like min, max return one row in case of no rows in table
From
jai.soni@elbizsystems.com
Date:
The following bug has been logged on the website: Bug reference: 11642 Logged by: Jai Soni Email address: jai.soni@elbizsystems.com PostgreSQL version: 9.3.0 Operating system: Open Suse Linux 12.1 Description: Aggregate Functions like min, max return one row in case of no rows in table it should return 0 rows as it return while using normal field in select query below code will re-create the case # create table dummy(fid integer); # select * from dummy; fid ----- (0 rows) # select max(fid) from dummy; max ----- (1 row)
Re: BUG #11642: Aggregate Functions like min, max return one row in case of no rows in table
From
Marko Tiikkaja
Date:
On 10/11/14, 9:31 AM, jai.soni@elbizsystems.com wrote: > Aggregate Functions like min, max return one row in case of no rows in table > it should return 0 rows as it return while using normal field in select > query According to whom? This behaviour is well defined in the SQL standard and documented for example here: http://www.postgresql.org/docs/9.3/static/sql-select.html#SQL-GROUPBY "Aggregate functions, if any are used, are computed across all rows making up each group, producing a separate value for each group (whereas without GROUP BY, an aggregate produces a single value computed across all the selected rows)." .marko