pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #11642: Aggregate Functions like min, max return one row in case of no rows in table
2+ messages / 2 participants
[nested] [flat]

* BUG #11642: Aggregate Functions like min, max return one row in case of no rows in table
@ 2014-10-11 07:31  jai.soni@elbizsystems.com
  0 siblings, 1 reply; 2+ messages in thread

From: jai.soni@elbizsystems.com @ 2014-10-11 07:31 UTC (permalink / raw)
  To: pgsql-bugs

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)



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #11642: Aggregate Functions like min, max return one row in case of no rows in table
@ 2014-10-11 09:14  Marko Tiikkaja <marko@joh.to>
  parent: jai.soni@elbizsystems.com
  0 siblings, 0 replies; 2+ messages in thread

From: Marko Tiikkaja @ 2014-10-11 09:14 UTC (permalink / raw)
  To: jai.soni@elbizsystems.com; pgsql-bugs

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


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2014-10-11 09:14 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-10-11 07:31 BUG #11642: Aggregate Functions like min, max return one row in case of no rows in table jai.soni@elbizsystems.com
2014-10-11 09:14 ` Marko Tiikkaja <marko@joh.to>

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