
Asked in Zensar Technologies and 5 others
Write a SQL query to find the fourth highest salary of an employee from an employee table.

To find the fourth highest salary from an employee table using SQL, we can use various methods like subqueries or the DISTINCT clause.
Use the DISTINCT keyword to get unique salaries: SELECT DISTINCT s...read more
WITH RankedSalaries AS (
SELECT Salary, ROW_NUMBER() OVER (ORDER BY Salary DESC) AS SalaryRank
FROM Employee
)
SELECT Salary
FROM RankedSalaries
WHERE SalaryRank = 4;
SELECT salary
FROM employees
ORDER BY salary DESC
LIMIT 1 OFFSET 3;
let us see with an example : To find 4th Highest salary query will be : Select Salary from table_name order by Salary DESC limit 3,1; Here we are skipping 3 rows from Top and returning only 1 row afte...read more
Using , we get nth salary from Windows Functions (or) OLAP Functions.
Densrank() doesn't skip the ranking position.
Syntax:- select column_names, densRank() over(order by column_name) rn from table_na...read more
Interview Questions from Popular Companies










Reviews
Interviews
Salaries
Users

