Subject Re: [firebird-support] select first & union
Author Nick Upson
almost, the problem is that the select first has no real meaning
without an order by on that select within the union, but an order by
at the point is not allowed

ideally I would do:

select first 25 skip 25 'A', id, result from ... ORDER BY id
union
select 2, count(*) from ...
order by 1, 2

but I'm not allowed to do the "ORDER BY id" because it's within the union

On 23/08/07, sasha <selectnull@...> wrote:
> >
> > if I have
> >
> > select first 25 skip 25 id from ......
> > union
> > select count(*) from ....
> > order by 1
> >
> > what should the order by apply to, I want it to apply to the
> > first select so the first/skip is correct but syntax does not
> > allow an order by until the end due to the union. Should I be
> > approaching this differently.
> >
> If I understood, you are trying to to put count(*) at the end, right? If
> that's so
> then this is the solution:
>
> select first 25 skip 25 1 order_by, result from ...
> union
> select 2, count(*) from ...
> order by 1
>
> Sasha