Subject Re: Select first 3 and last 3 records
Author mailmur
> I need to select the first 3 and last 3 records from a transaction
file This I would imagine would be a simple query as the example below
however Firebird objects to the "order by" clause when a "union"
operator is present
> select first 3 PrnId, InvNo
> from Ordtrn
> where PrnId='21'
> order by InvNo
> union
> select first 3 PrnId, InvNo
> from Ordtrn
> where PrnId='21'
> order by InvNo desc

Maybe a derived inner queries could solve this problem.
Select a.* From
(Select first 3 prnid, invno From Ordtrn ... Order by Invno asc) a
UNION
Select b.* From
(Select first 3 prnid, invno From Ordtrn ... Order by Invno desc) b