Subject Re: Select first 3 and last 3 records
Author Adam
Hello Cao,

The reason you cant use order by is that it would be ordered after the
union not before. The other solution would work in V2.

You could turn it into a selectable Stored Procedure

create procedure blah
returns
(
PrnID integer,
InvNo integer
)
as
begin
for select first 3 PrnId, InvNo
from Ordtrn
where PrnId='21'
order by InvNo
into :PrnID, :InvNo
do
begin
suspend;
end

for select first 3 PrnId, InvNo
from Ordtrn
where PrnId='21'
order by InvNo desc
into :PrnID, :InvNo
do
begin
suspend;
end
end
^

if you are worried about duplicates, you could always do

select distinct *
from Blah

By the way, this would be a very slow operation unless you have both
an ascending and descending index on that table.

Hope that gives you some ideas
Adam