One common problem when developing database applications is to show the first n rows of a set, ordering the data in a specific manner. For example, if we want to see the last 10 articles submitted in a web application.
In this recipe, we will see how to obtain this scope and how to obtain it faster.
The following steps will demonstrate how to get the top n queries and their ranking:
SELECT CUST_ID, CUST_FIRST_NAME, CUST_LAST_NAME, CUST_YEAR_OF_BIRTH FROM CUSTOMERS WHERE ROWNUM < 11 ORDER BY CUST_YEAR_OF_BIRTH DESC;