Subject | Re: does "group by" imply "order by" |
---|---|
Author | Adam |
Post date | 2007-09-07T04:37:16Z |
--- In firebird-support@yahoogroups.com, "bill2janesoft@..."
<bill2janesoft@...> wrote:
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.
Adam
<bill2janesoft@...> wrote:
>standard,
> AFAIK "group by" does not guarantee "order by" at least in older sql
> but it usually worked without the additional "order by" clause. I'mcurious to
> know if this is now guaranteed in newer sql standard or firebirdimplementation.
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.
Adam