Subject Re: [firebird-support] Re: Select first 3 and last 3 records
Author Kjell Rilbe
Oops, forgot the '21' condition. Try this instead:

select ...
from Ordtrn O1
where PrnId = '21'
and (
(
select count(*)
from Ordtrn O2
where O2.InvNo <= O1.InvNo
and PrnId = '21'
) <= 3
or (
select count(*)
from Ordtrn O2
where O2.InvNo >= O1.InvNo
and PrnId = '21'
) <= 3
)

Kjell

Kjell Rilbe wrote:

> select ...
> from Ordtrn O1
> where (
> select count(*)
> from Ordtrn O2
> where O2.InvNo <= O1.InvNo
> ) <= 3
> or (
> select count(*)
> from Ordtrn O2
> where O2.InvNo >= O1.InvNo
> ) <= 3
--
--------------------------------------
Kjell Rilbe
Adressmarknaden AM AB
E-post: kjell.rilbe@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64