I have two tables employees and departments.

Employees table has name, salary, department\_id.
Departments table has department\_id, department\_name

I have to display the employee with the second highest(Literally the only one employee who has the second highest salary among every employee in the employees table) and his department\_name using subqueries

```
select 
    max(e.salary),
    d.department_name 
from oehr_employees e 
join oehr_departments d on(e.department_id = d.department_id) 
where e.salary not in(
    select max(salary) from oehr_employees
) 
group by department_name

```

tried to do this one, but it shows only the second highest salary of each department. Have no idea what to do :/

Tried searching for answers but didn't quite get what I wanted.