Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

mysql get nth highest

CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
  SET N = N-1;
  
  RETURN (
      # Where Salary is your column name and Employee your table
      SELECT DISTINCT(Salary) FROM Employee ORDER BY Salary DESC LIMIT N, 1
  );
END
 
PREVIOUS NEXT
Tagged: #mysql #nth #highest
ADD COMMENT
Topic
Name
3+2 =