Re: [GENERAL] Problem with a GROUP BY clause

From: Mike Mascari <mascarim(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Cc: mdalphin(at)amgen(dot)com
Subject: Re: [GENERAL] Problem with a GROUP BY clause
Date: 1999-08-01 18:05:31
Message-ID: 19990801180531.7835.rocketmail@web113.yahoomail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

--- Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il> wrote:
> At 03:52 +0300 on 01/08/1999, Mark Dalphin wrote:
>
>
> > There is no row, yet Postgresql reports there is
> "one" which it returns as
> > empty. This also makes the Perl DBI::DBD
> interface unhappy. It seems to
> >return
> > an undefined value which can't even be tested with
> "if(! defined $value)"!
> >
> > Unless I really misunderstand "GROUP BY", I think
> this is a bug.
>
> We had this discussion in the past and I think you
> are right in saying that
> under "GROUP BY", this behaviour is a bug. However,
> it is not really that
> hard to handle. It merely returns a row with NULL
> values all over. Test for
> NULL in the same way you test for NULL in any field
> that may have NULL
> values. You can be sure that if a valid grouping was
> returned, neither
> field will be null.
>
> Herouth

Of course, one way to get around the bug until it is
fixed (although I don't see it on the TODO...) is to
issue the query like this:

select field1, max(field2) from table1
group by field1 having max(field2) is not null;

Hope that helps,

Mike Mascari (mascarim(at)yahoo(dot)com)

_____________________________________________________________
Do You Yahoo!?
Free instant messaging and more at http://messenger.yahoo.com

Browse pgsql-general by date

  From Date Subject
Next Message Guillermo Villavicencio Ugarte 1999-08-01 18:17:35
Previous Message Robert J. Sprawls 1999-08-01 15:58:18 Re: [ADMIN] Install problems (libpq.so.1)