PL/SQL Cursor to Display Record having Third Highest Salary

PL/SQL Cursor to Display Record having Third Highest Salary:

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

OUTPUT:

5 400000 Los Angeles

Leave a Reply

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

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