Display top 7 records from emp table

Select * from (select row_number() over(order by empno) rn,e.* from emp e )
Where rn<=7 ;

OUTPUT

RN EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
1 7369 SMITH CLERK 7902 17-DEC-80 800 null 20
2 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
3 7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
4 7566 JONES MANAGER 7839 02-APR-81 2975 null 20
5 7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
6 7698 BLAKE MANAGER 7839 01-MAY-81 2850 null 30
7 7782 CLARK MANAGER 7839 09-JUN-81 2450 null 10

output on tool

Display top 7 records from emp table
Retrieve top 7 records from emp table

Leave a Reply