How do I limit the number of records returned for Interbase 7.1?
Asked Answered
R

2

7

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.

Thanks in advance!

Refill answered 24/6, 2009 at 19:26 Comment(0)
R
15

I think I figured it out. Needed to do something like this...

SELECT * FROM table ORDER BY col ROWS 1
Refill answered 24/6, 2009 at 19:43 Comment(0)
C
9

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:

Curren answered 8/2, 2013 at 0:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.