pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Len Morgan <len-morgan@crcom.net>
To: pgsql-sql@postgresql.org
Subject: Agregate Problem?
Date: Sun, 15 Aug 1999 09:01:36 -0500
Message-ID: <000501bee726$b7aa08e0$0908a8c0@H233.bstx.com> (raw)

I am having a problem with queries that have an aggregate (sum in this case)
when no rows meet my criteria.  I still get back a row with null values for
all fields.  Is this the correct behavior?  I am trying to sum up daily
sales quanties by items and if I don't have any sales on a particular day, I
want to print nothing.  I thought I could do this by detecting a 0 row count
but since I have the aggregates, I still 1 row.

Example:

SELECT itemno,sum(qty) FROM sales WHERE sale_date = 'now()::date'

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?"

Thanks

Len Morgan




view thread (3+ messages)  latest in thread

Message-ID: <000501bee726$b7aa08e0$0908a8c0@H233.bstx.com>
Permalink:  ../000501bee726$b7aa08e0$0908a8c0@H233.bstx.com/
Also on:    postgresql.org/message-id/000501bee726$b7aa08e0$0908a8c0@H233.bstx.com

 · 

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: len-morgan@crcom.net
  Subject: Re: Agregate Problem?
  In-Reply-To: <000501bee726$b7aa08e0$0908a8c0@H233.bstx.com>
  References: <000501bee726$b7aa08e0$0908a8c0@H233.bstx.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