Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Nth Highest Salary Query

EasySQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is SQL Nth Highest Salary Query. Start with the requirements and the one table on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

EXL Service Philippines uses salary analysis in its HR reporting workflows. Write a PostgreSQL query to return the third-highest distinct salary from the employee_salaries table.

Requirements

  1. Exclude NULL salaries before ranking salary levels.
  2. Return exactly one row containing the third-highest distinct salary. Treat the highest salary as position 1.

Schema

employee_salaries
ColumnTypeDescription
employee_idPKINTEGERUnique employee identifier
employee_nameVARCHAR(100)Employee's full name
salaryINTEGERAnnual salary in Philippine pesos
Tablesemployee_salaries
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results