Subject RE: [firebird-support] Re: Select first 3 and last 3 records
Author Cao Ancoinc
Thanks to everyone for replying

The final result was to use a stored procedure which I really did not want
to do for a once off query but Norbets solution (with tweaking) was the most
efficient.

Regards Cao

> > Thanks MailMur however
> > as far as I know the From Select statement will only be
> implemented in Ver 2
> > so I am back to my original problem
>
> Perhaps this way:
>
> CREATE PROCEDURE PRC_XXXX (
> PRNID CHAR(002))
> RETURNS (
> PRNID INTEGER,
> INVNO INTEGER )
> AS
> BEGIN
> /* First 3 records selection... */
> FOR SELECT FIRST 3 PRNID
> , INVNO
> FROM ORDTRN
> WHERE PRNID = :PRNID
> ORDER BY INVNO ASC
> INTO :PRNID,
> :INVNO
> DO
> BEGIN
> SUSPEND;
> END
>
> /* Last 3 records selection... */
> FOR SELECT FIRST 3 PRNID
> , INVNO
> FROM ORDTRN
> WHERE PRNID = :PRNID
> ORDER BY INVNO DESC
> INTO :PRNID,
> :INVNO
> DO
> BEGIN
> SUSPEND;
> END
> END
>
> Regards,
> Norbert
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://firebird.sourceforge.net and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>