PL/SQL Cursor to Display Last Five Records having Highest Salary

PL/SQL Cursor to Display Last Five Records having Highest Salary:


declare 
cursor hsal is select * from student order by salary desc;
cnt number;
begin
cnt:=1;
for i in hsal
loop
if(cnt<=3) then
dbms_output.put_line(i.id||' '||i.salary||' '||i.city);
cnt:=cnt+1;
end if;
end loop;
end;

OUTPUT:

3 5000000 HongKong
4 500000 Mumbai
5 400000 Los Angeles
1 150000 New York
6 100000 San Diego



Leave a Reply

Your email address will not be published. Required fields are marked *

12 + 18 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.