Subject Re: Problems with Order by
Author Alexander V.Nevsky
--- In firebird-support@yahoogroups.com, Rosivaldo Azevedo Ramalho
<rosivaldo@p...> wrote:
> Hello guys,

Rosivaldo, starting in such a manner you are risking to do'nt get
answer from some very skilled persons here, who are girls ;)

> i'm new using firebird, and i'm having some trobles with a
> order by in a sql union statement.
>
> For example..
> select * from clients where id > 100
>
> union
>
> select * from clients where id < 200
>
> order by date
>
> Doesn't work, but if i run the sql without the "order by" it works just
> fine.

In union we can use only order by <number of the column in returned
resultset>, like

Select a, b
From table1
Union
Select a, b
From table2
Order by 1 /*this is column 'a'*/

in simple select we can use both column name and column number.

Best regards,
Alexander