Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Nth Salary SQL

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

Your question is Nth Salary SQL. 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

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
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results