Re: [GENERAL] Problem with a GROUP BY clause

Поиск
Список
Период
Сортировка
Искать

Re: [GENERAL] Problem with a GROUP BY clause

От:
Mike Mascari <mascarim@yahoo.com>
Дата:
--- Herouth Maoz  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@yahoo.com)

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

FAQ