By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,851 Members | 1,752 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,851 IT Pros & Developers. It's quick & easy.

Getting just the first couple records

P: n/a

How do I retrieve just the first dozen records of a few ten thousand
records?

SELECT * FROM TheTableOfNames

I tried to set up a SEQUENCE s, and come up with a SELECT statement
that would constrain the result set to the records that don't exceed a
given value for the sequence value:

Index Name
-- ------
1 Alice
2 Bob
3 Cindy
4 Dave
5 Eve
....

SELECT Index, Name
FROM ...
WHERE Index < 3

What is the proper way to do this in DB2? Is there sth like a row index
in the result set that I could use in the WHERE clause?

mtia

Claus

Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Ooops. That's in the FAQ. Sorry I overlooked it:

SELECT ... FETCH FIRST n ROWS ONLY OPTIMIZE FOR n ROWS

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.