Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Nth Salary SQL
00:00
5 left

Nth Salary SQL

MediumSQL · PostgreSQL

Problem

Write a SQL query to find the nth salary.

Treat salaries as distinct values, ignore NULL salaries, and use n = 3 for this exercise.

Output

  1. Return one row with one column named nth_salary.
  2. Return the third-highest distinct non-NULL salary.

Schema

employees
ColumnTypeDescription
employee_idPKINTUnique employee identifier
employee_nameVARCHAR(100)Employee name
departmentVARCHAR(80)Employee department
salaryNUMERIC(12,2)Annual employee salary
Tablesemployees
Interviewer

Your question is Nth Salary SQL. Start with the requirements and the one table in the Question tab.

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.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.