5 different ways || Detailed explanation
Finding the highest salary\n\nselect MAX(Salary) from Employee;\nfinding the 2nd highest salary\n\n\nQuery-1\n\n\nSELECT MAX(Salary) FROM Employee\nWHERE Salary
**Finding the highest salary**\n```\nselect MAX(Salary) from Employee;\nfinding the 2nd highest salary\n```\n\n**Query-1**\n\n```\nSELECT MAX(Salary) FROM Employee\nWHERE Salary NOT IN (SELECT MAX(Salary) FROM Employee);\n```\n\n**Query-2**\n```\nselect MAX(Salary) from Employee\nWHERE Salary <> (select MAX(Salary) from Employee )\n```\n---\n**Finding the Nth highest salary**\n\n**Query-1**\n```\nSELECT * /*This is the outer query part */\nFROM Employee Emp1\nWHERE (N-1) = ( /* Subquery starts here */\nSELECT COUNT(DISTINCT(Emp2.Salary))\nFROM Employee Emp2\nWHERE Emp2.Salary > Emp1.Salary)\n```\n\n**Query-2**\n```\nSELECT *\nFROM Employee Emp1\nWHERE (1) = (\nSELECT COUNT(DISTINCT(Emp2.Salary))\nFROM Employee Emp2\nWHERE Emp2.Salary > Emp1.Salary)\n```\n---\n\n**Nth highest salary in *MySQL***\n```\nSELECT Salary FROM Employee \nORDER BY Salary DESC LIMIT n-1,1\n```\n---\n\n**Nth highest salary using the *TOP keyword in SQL Server***\n```\nSELECT TOP 1 Salary\nFROM (\n      SELECT DISTINCT TOP N Salary\n      FROM Employee\n      ORDER BY Salary DESC\n      ) AS Emp\nORDER BY Salary\n```\n\n**Nth highest salary in *SQL Server***\n\n```\nSELECT Salary FROM Employee \nORDER BY Salary DESC OFFSET N-1 ROW(S) \nFETCH FIRST ROW ONLY\n```\n---\n\n**Nth highest salary in Oracle using *rownum***\n```\nselect * from (\n  select Emp.*, \nrow_number() over (order by Salary DESC) rownumb \nfrom Employee Emp\n)\nwhere rownumb = n;  /*n is nth highest salary*/\n```\n\n**Nth highest salary in *Oracle using RANK***\n```\nselect * FROM (\nselect EmployeeID, Salary\n,rank() over (order by Salary DESC) ranking\nfrom Employee\n)\nWHERE ranking = N;\n```\n\n\n*Note:* **If you like the content please upvote for further such explanation \uD83D\uDE4F**
['MySQL', 'Oracle']