Subject Re: does "group by" imply "order by"
Author Adam
--- In, "bill2janesoft@..."
<bill2janesoft@...> wrote:
> AFAIK "group by" does not guarantee "order by" at least in older sql
> but it usually worked without the additional "order by" clause. I'm
curious to
> know if this is now guaranteed in newer sql standard or firebird

My understanding is that the sorting is an implementation artifact of
the group by algorithm used by the Firebird engine. I do not believe
the SQL standard says anything about an implicit order by and I
wouldn't make presumptions about how other DBMS will behave without an
order by clause.

Officially, if you do not state an order by in your query, you are
instructing the engine that you are happy for the records to be
returned in an arbitrary order. The engine is still doing its job if
it returns an ordered set if you don't provide an order by clause.

No-one will stop you from omitting the order by clause and I am not
aware of any plans to seriously change the methodology of a group by,
but if you choose to omit it, then don't complain if Firebird changes
algorithms at some time in the future.