Re: Limiting number of rows in result sets
Posted in 1997
Randy Baker wrote:
>
> I have a customer who is interested in running our ODBC-based
> application
> on Informix. The application was originally targeted for SQL Server,
> and
> uses the SQL Server specific feaure "SET ROWCOUNT n" to cap the number
> of
> rows returned or processed by a query in some situations.
>
> Does Informix support a comparable feature?
Not directly, but try:
SELECT cols
FROM table
WHERE no_rows > (
SELECT COUNT(*)
FROM same_table
WHERE same_table.primary_key <
table.primary_key
)
where no_rows is the number of rows to return.
The following returns the first ten customer numbers from the customer
table:
SELECT customer_num
FROM customer
WHERE 10 > (
SELECT COUNT(*)
FROM customer c
WHERE c.customer_num < customer.customer_num
)
Hope that helps,
--
Mark.
+----------------------------------------------------------+-----------+
|Mark D. Stock - Informix SA http://www.informix.com |//////// /|
|mailto:mdstock@informix.com FAQ http://www.iiug.org |///// / //|
| +-----------------------------------+//// / ///|
| Tel: +27 11 807 0313 |If it's slow, the users complain. |/// / ////|
| Fax: +27 11 807 2594 |If it's fast, the users keep quiet.|// / /////|
|Cell: +27 83 250 2325 |Therefore, "No news: travels fast"!|/ ////////|
+----------------------+-----------------------------------+-----------+