Subject Re: [firebird-support] Re: union
Author Kjell Rilbe
danyschaer wrote:
> Thanks Dmitry,
>
> The way I see that works with Firebird an the others engines (Oracle, Postgres) is:
>
> select * from (select "FECH","HECH" from "MOVI" where "HECH"='P' order by "FECH") A1
> union
> select * from (select "FECH","HECH" from "MOVI" where "HECH"='P' order by "FECH") A2

You can do it like this if you want to make sure all the records from
the first subquery to appear first:

select "FECH", "HECH"
from (
select 1 "Q", "FECH", "HECH"
from "MOVI"
where "HECH" = 'P'
union
select 2 "Q", "FECH", "HECH"
from "MOVI"
where "HECH"='P'
) SubQ
order by "Q", "FECH";

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