Re: Problem with the group statement...

From: Steve Kass <skass_at_drew.edu>
Date: Fri, 19 Jul 2002 01:54:18 -0400
Message-ID: <3D37A98A.77A31BF3_at_drew.edu>


As far as the SQL-92 standard goes,

select ...
from ...
group by ...

is just a "bag" of rows with no ordering, regardless of whether some predictable order results in a particular implementation. The only result sets that are returned to the user with an ordering are multiple row queries that contain an order by clause.

According to the standard, to some extent

select ...
from ...
group by ...

and

select ...
from ...
[group by ...]
order by ...

are different kinds of objects. The first is a query specification, and the second is a cursor specification. They can both be used as direct select statements, but as such, again only the one with order by has a defined ordering.

The FIRST() and LAST() aggregate functions do not exist in the SQL-92 standard. They are proprietary extensions.

Steve Kass
Drew University

GoranG wrote:

> On Thu, 18 Jul 2002 13:12:39 +0200, "Volker Hetzer"
> <volker.hetzer_at_ieee.org> wrote:
>
> >
> >"Lennart Jonsson" <lennart_at_kommunicera.umea.se> wrote in message news:6dae7e65.0207170906.5d1c6712_at_posting.google.com...
> >> [Good explanation of grouping]
> >> the order by is applied last
> >So the result of the group clause is sorted.
> >
> >Lots of thanks!
> >Volker
>
> Hhmm, not sure about that.
>
> I don't think so, but still check the reference(s) - I think that
> sorting occurs before grouping. This is neccessary for First() and
> Last() aggregate functions to work properly.
> Still I have not used First and Last for a whiiiile.
>
> Anybody knows what does the standard say?
>
> ( GoranG79 AT hotmail.com )
Received on Fri Jul 19 2002 - 07:54:18 CEST

Original text of this message