Header Ads

Header ADS

Oracle / PLSQL: ROWNUM Function

Use of ROWNUM Function In Oracle

Topic Introduction: In this tutorial, we will discuss the Use of  ROWNUM Function In Oracle which is the most powerful and important function in oracle. when we execute any SQL query it can return two or many more rows. here return the column which column we specified or if we use * from any table it will return all columns of the specified table. But here the ROWNUM pseudocolumn returns a number indicating the order in which Oracle selects the row from the query. The first row selected has a ROWNUM of 1, the second has 2, and so on which we can view using ROWNUM on SQL Query.

ROWNUM function in Oracle/PLSQL there are no parameters or arguments. The ROWNUM function is sometimes referred to as a pseudo column in Oracle. its function returns a numeric value. 

Use of ROWNUM Function. 

we can use ROWNUM to limit the number of rows returned by a query

SELECT * FROM employees WHERE ROWNUM < 10;

Top 5 salary paid employee list

Select rownum,last_name, job_id, salary
from(
SELECT rownum,last_name, job_id, salary
FROM employees
ORDER BY salary DESC
)
where rownum<=5



Note: There has more use of ROWNUM on oracle. Need to know the basics then we will be able to understand where we can apply this function for proper result









No comments

Theme images by Deejpilot. Powered by Blogger.