A company's compensation analytics team needs to identify employees at the third-highest distinct salary among active employees. Write a PostgreSQL query that returns every employee tied at that salary and includes the department name when available.
Requirements
- Consider only active employees with non-NULL salaries.
- Rank distinct salary levels from highest to lowest and select the third level, not merely the third row.
- Return all employees tied at that salary with their employee ID, name, salary, and department name. Preserve qualifying employees even when their department is missing.
Output details
- Return columns named
employee_id, employee_name, salary, and department_name in that order.
- Sort by
salary descending, then by employee_id ascending.