logo

Oracle NextGen

score

SQL Challenge

Challenge #12 – Second Highest Salary

Challenge Overview
Find the second highest salary in each department. If a department has only one employee, return NULL.

Requirements

  • Return columns: department, second_highest_salary.
  • Use window functions or subqueries.
  • Handle departments with fewer than 2 employees.
  • Order by department alphabetically.
Sample Dataset
Preview the schema and seeded rows you can query against.

employees

Employee salary data.

Columns
NameTypeNotes
employee_idINTPrimary key
employee_nameVARCHAREmployee name
departmentVARCHARDepartment
salaryDECIMALAnnual salary
Sample Rows
employee_idemployee_namedepartmentsalary
1AliceEngineering95000
2BobEngineering85000
3CharlieEngineering90000
4DianaSales70000
5EveSales65000
6FrankHR60000
SQL Playground
Loading editor…

Result Preview

Awaiting Run

Run your query to see the dataset preview.