Ask the Expert

FETCH FIRST n ROWS ONLY functionality in Oracle

How can I limit the resulting rows of an ordered SELECT statement without using a nested select with order clause in the inner select? In DB2 SQL, I currently use the FETCH FIRST n ROWS ONLY.

    Requires Free Membership to View

Oracle does not have the same functionality that you describe in DB2. Oracle's solution to the problem is to use the nested SELECT with an ORDER BY clause to limit rows. Oracle 9i may be able to help your problem by introducing new analytical functions like RANK and DENSE_RANK. But you'd need to have some paritioning column to make those functions work for you.

For More Information

This was first published in May 2003

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: