PayPal Interview Question | Highest Salary
Question
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
It will take less than 1 minute to register for lifetime. Bonus Tip - We don't send OTP to your email id Make Sure to use your own email id for free books and giveaways
Answers ( 2 )
select salary from
(select *, dense_rank over(order by salary desc) as sal) from employee as e
where e.sal=5;
Dense rank will assign ranks according to the descending order of the salary. If the salary of two employee are same, it will give the same rank and will not skip the next number.
Select first_name, salary, s.salary_rank from (
select *, dense_rank() over(order by salary) as salary_rank from salary) s
where s.salary_rank = 5
Select first_name, salary from salary
order by salary desc
limit 1 offset 4;
Using window function dense_rank enables us to display the rank as well in the output.