Write an SQL query to report the nth highest salary from the Employee table. If there is no nth highest salary, the query should report null.
The query result format is in the following example.
① 함수생성 DDL 명령어
② 함수명 정의
③ 함수 파리미터 선언
④ 리턴 타입 지정
⑤ 함수에서 사용할 변수 선언
⑤ 함수 결과 리턴
create function getNthHighestSalary(N IN NUMBER)
return NUMBER
is
result NUMBER;
BEGIN
select salary into result
from (select rownum,salary
from (select distinct salary
from employee order by salary desc))
where rownum = N;
RETURN result;
END;