Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limit # of rows returned in SQL

Status
Not open for further replies.

Sparc

Programmer
Jun 20, 2001
4
US
I'm trying to code an SQLRPGLE program to return a set # of rows from a file but have so far been unsuccessful. Anyone know of a keyword or formula that i may have overlooked?

All i want to do is return the first 25 records from a file containing 400 records. Should i try to key off of the relative record number in the file?
 
I think it is the keyword ROWS, but I am not positive. I would look it up on the online DB2 books on IBM's web site. Mike Wills
AS400 Programmer
 

try using FETCH FIRST n ROWS ONLY where n is an integer corresponding to the number of rows you want.
 
SQL permits use of something like

SELECT TOP 25 * FROM
or
SELECT TOP 25 PERCENT * FROM

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top