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.

Dig Deeper on IBM DB2 management

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.

Please create a username to comment.

-ADS BY GOOGLE

SearchBusinessAnalytics

SearchAWS

SearchContentManagement

SearchOracle

SearchSAP

SearchSQLServer

Close