Subject Re: [firebird-support] How to eliminate long GROUP BY?
Author Kjell Rilbe
Gabor Boros wrote:
> I always have problem with GROUP BY when work on a complex query because
> every selected field must be listed in GROUP BY. And I hate this thing.
> I found this: http://www.firebirdfaq.org/faq304
> Is this an official and safe solution?

The trick is that if the group by groups by a primary key, then there
will only be one record from that table in each aggregate row, so min
and max will return the value itself.

This is safe as long as you group by the primary key (or any unique key)
of table T and apply min/max only to columns selected from (the same)
table T.

Kjell
--
------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell.rilbe@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64


[Non-text portions of this message have been removed]