Reputation: 3
I am trying to write a PL/SQL
Function to return Nth highest Salary. I keep getting the Runtime error below. The error is on 'Return result;' line
PL/SQL: ORA-00933: SQL command not properly ended ORA-06575: Package or function GETNTHHIGHESTSALARY is in an invalid state
Code:
CREATE FUNCTION getNthHighestSalary(N IN NUMBER) RETURN NUMBER IS result NUMBER;
BEGIN
select Salary into result
from
(select dense_rank() over (order by salary desc) as Ranks, ID, Salary
from Employee) a
where a.Ranks = N
RETURN result;
END;
Upvotes: -2
Views: 495
Reputation: 30665
You have missing semi-colon where a.Ranks = N
. It is supposed to be where a.Ranks = N;
Upvotes: 2