Q
Problem solve Get help with specific problems with your technologies, process and projects.

Finding the 10 greatest numbers in a column

What is the best way finding the greatest 10 numbers from a column without doing a lot of sorting by writing a simple SQL?

The best way to do this is to use a query similar to this one:

SELECT   DISTINCT COL 
FROM     TABLE 
ORDER BY COL DESC 
FETCH FIRST 10 ROWS ONLY; 
The ORDER BY clause will sort the data into descending by COL values; The FETCH FIRST 10 ROWS ONLY clause will limit your output to 10 rows only. The DISTINCT in the SELECT-list will eliminate duplicates. If you want to keep the duplicates, just remove the DISTINCT parameter.

This was last published in January 2003

Dig Deeper on IBM DB2 management

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

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

Please create a username to comment.

-ADS BY GOOGLE

SearchBusinessAnalytics

SearchAWS

SearchContentManagement

SearchOracle

SearchSAP

SearchSQLServer

Close