Subject RE: [firebird-support] FIRST m SKIP n problem
Author Leyne, Sean
Yves,

> I want to retrieve the last 4 things joe has done, ordered by
> datetime (asc).
>
> So using FIRST 4 and use 'desc' order is not ok... :-(
>
> How can I do that (using FB1.03)?


Step 1 -- Create select SP

CREATE PROCEDURE GET_LAST_4_ENTRIES
(
EmployeeName VarCHAR( 80)
)
RETURNS
(
datetime date,
blabla bla
)
AS
BEGIN
For
SELECT FIRST 4
:datetime
:blabla
FROM <table> T
WHERE
Name = :EmployeeName
Order By
Datetime desc
Into
:datetime
:blabla
Do
Begin
Suspend;
end
END;


Step 2 - Use SP as virtual table

SELECT
*
From
GET_LAST_4_ENTRIES( {EmployeeName})
Order by
Datetime


Sean