We have an Interbase 7.1 database and I'm trying to figure out how to limit the number of records returned by the query to just 1. I really only need to know an event code from the last record, in which the query will return hundreds of records if I cannot do some kind of limit.
我们有一个Interbase 7.1数据库,我正在试图弄清楚如何将查询返回的记录数限制为1.我真的只需要知道上一条记录中的事件代码,其中查询将返回数百条记录,如果我不能做某种限制。
Thanks in advance!
提前致谢!
2 个解决方案
#1
I think I figured it out. Needed to do something like this...
我想我明白了。需要做这样的事......
SELECT * FROM table ORDER BY col ROWS 1
#2
As per the accepted answer:
根据公认的答案:
SELECT * FROM table ORDER BY col ROWS 1
Will return just one result. There are also several other row limiting options available:
只返回一个结果。还有其他几种行限制选项:
ROWS n Returns the first n rows of the result set, or n percent if used with PERCENT ROWS m TO n Returns rows m through n, inclusive or the mth to nth percent ROWS n BY p Returns every pth row of the first n rows
This is particularly handy for paged results.
这对于分页结果尤其方便。
From the Embedded SQL Guide on the InterBase Product Documentation page:
从InterBase产品文档页面上的嵌入式SQL指南:
#1
I think I figured it out. Needed to do something like this...
我想我明白了。需要做这样的事......
SELECT * FROM table ORDER BY col ROWS 1
#2
As per the accepted answer:
根据公认的答案:
SELECT * FROM table ORDER BY col ROWS 1
Will return just one result. There are also several other row limiting options available:
只返回一个结果。还有其他几种行限制选项:
ROWS n Returns the first n rows of the result set, or n percent if used with PERCENT ROWS m TO n Returns rows m through n, inclusive or the mth to nth percent ROWS n BY p Returns every pth row of the first n rows
This is particularly handy for paged results.
这对于分页结果尤其方便。
From the Embedded SQL Guide on the InterBase Product Documentation page:
从InterBase产品文档页面上的嵌入式SQL指南: