pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Herouth Maoz <herouth@oumail.openu.ac.il>
Cc: Len Morgan <len-morgan@crcom.net>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Agregate Problem?
Date: Sun, 15 Aug 1999 11:48:41 -0400
Message-ID: <10079.934732121@sss.pgh.pa.us> (raw)
In-Reply-To: <l03130309b3dc7e410a29@[147.233.159.109]>

> At 17:01 +0300 on 15/08/1999, Len Morgan wrote:
>> SELECT itemno,sum(qty) FROM sales WHERE sale_date = 'now()::date'

This is invalid as it stands --- you need "GROUP BY itemno" because of
the aggregate function.  (IIRC, Postgres versions before 6.5 were a bit
lax about checking for that error.)

>> I would expect to get back zero rows if there were no sales today but I get
>> back 1.  Of course I also get back 1 row if I only sold 1 item.  Is this a
>> bug or a "feature?"

Herouth Maoz <herouth@oumail.openu.ac.il> writes:
> This is a correct behaviour when there is no GROUP BY. PostgreSQL does this
> in GROUP BY, too, unfortunately.

I believe we finally agreed that producing an empty row when there is a
GROUP BY is a bug (there was some debate about it).  I intend to change
that behavior for 6.6, but haven't actually done it yet...

			regards, tom lane



view thread (3+ messages)

Message-ID: <10079.934732121@sss.pgh.pa.us>
Permalink:  ../10079.934732121@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/10079.934732121@sss.pgh.pa.us

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, herouth@oumail.openu.ac.il, len-morgan@crcom.net
  Subject: Re: [SQL] Agregate Problem?
  In-Reply-To: <10079.934732121@sss.pgh.pa.us>
  References: <l03130309b3dc7e410a29@[147.233.159.109]> <10079.934732121@sss.pgh.pa.us>

* 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