Amazon's Business Analyst Interview Question
Amazon's Business Analyst Interview Question
Amazon's Business Analyst Interview Question
dept_id int,
dept_name varchar(25));
Solution1
Note: This will not handle the situation when there is a tie between 2nd highest for two or more
than 2 department.
Solution3
Solution4
select dept_name,dept_avg_sal
from cte c1 where 2 =
(select count(distinct dept_avg_sal) from cte c2 where c2.dept_avg_sal >= c1.dept_avg_sal)
group by dept_name,dept_avg_sal;