From: Tom Lane <tgl@sss.pgh.pa.us>
To: M.Mazurek@poznan.multinet.pl
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] date_part, too many results?
Date: Thu, 24 Feb 2000 19:46:20 -0500
Message-ID: <23632.951439580@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.BSF.4.21.0002242237050.31209-100000@arka.poznan.mtl.pl>
References: <Pine.BSF.4.21.0002242237050.31209-100000@arka.poznan.mtl.pl>
M.Mazurek@poznan.multinet.pl writes:
> clicked table is empty for bannerid=1, so why is that row? How to get rid
> bannerdb=> select count(*),date_part('dow',data::datetime) from clicked
> where bannerid=1 group by date_part('dow',data::datetime);
> count|date_part
> -----+---------
> 0|
> (1 row)
It's not date_part's fault, it's count's fault. There should be no rows
out if you have GROUP BY and no groups, but 6.5 and prior Postgres
releases emit a dummy row anyway. This is a longstanding bug in
Postgres's handling of aggregate functions. It's fixed for 7.0, if you
want to try running the beta version... if not, you could add
HAVING count(*) > 0 as a temporary workaround.
regards, tom lane
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, M.Mazurek@poznan.multinet.pl
Subject: Re: [SQL] date_part, too many results?
In-Reply-To: <23632.951439580@sss.pgh.pa.us>
References: <Pine.BSF.4.21.0002242237050.31209-100000@arka.poznan.mtl.pl> <23632.951439580@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