Let's us Consider
Employee_Master table it contains Columns
Namely: Emp_ID,First_Name,Last_Name, and Salary We will write a
CTE(Common Table Expression) to find 2nd highest salary:-
WITH Employee_Dtls AS
(
SELECT SALARY,
DENSE_RANK() OVER(ORDER BY SALARY DESC) AS DENSERANK
FROM EMPLOYEE_Master
)
SELECT TOP 1 SALARY
FROM Employee_Dtls
WHERE DENSERANK = 2