¨ú¦Û www.delphi3000.com, §@ªÌ¡GKevin Lawrence
Question
How does one limit the number of rows included in a query: e.g
how does one get the top (or bottom) 10 sales totals?
Answer
Use a stored procedure that accepts the number of rows you want
returned (this is a little more flexible than hard coding the
number of rows).
create procedure p_get_n_records(iMaxRecords INTEGER)
returns ()
as
DECLARE VARIABLE iCount INTEGER;
BEGIN
iCount = 0;
FOR SELECT
FROM
INTO :
DO
BEGIN
iCount = iCount + 1;
IF (iCount <= iMaxRecords) THEN
SUSPEND;
ELSE
EXIT;
END
END
               (
geocities.com/huanlin_tsai)