FastPrepSecond-Highest Distinct Salary
Problems/Second-Highest Distinct Salary

Second-Highest Distinct Salary

Deloitte logoDeloitte● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionConstraints

Problem statement

Source note: Reported in a Deloitte phone screen. The interviewer asked for a SQL query that finds the second-highest salary.

The report does not give the table, how repeated salaries count, the output column, or what to return when there is no second salary. Here, the employee table has an id and a salary, equal salaries count once, and the single result row holds NULL when there is no second salary.

Our version is about 90% the same as the reported question.

The employee table has one row per employee: a unique id and an integer salary.

Write a query that finds the second-highest distinct salary. Employees who earn the same amount count as one salary value. Return exactly one row with one column named second_highest_salary. If there are fewer than two distinct salaries, that row holds NULL.

Table schema

MySQLPostgreSQLPandas

Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.

employee

One row per employee.

ColumnTypeNullableDescription
idPKIntegerNo—
salaryIntegerNo—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
second_highest_salaryIntegerYes—

Row order: must match exactly. Numeric tolerance: 0.

Constraints

  • id is a unique positive integer. No value is null.
  • 0 <= salary <= 1000000
  • The table has at most 1000 rows and may be empty.

More Deloitte interview questions

  • Check AnagramsONSITE INTERVIEW · Seen Jun 2026
  • Seventh Nearest PalindromeOA · Seen May 2026
  • Minimum Deletions for a Non-PalindromeOA · Seen Jul 2025
  • Minimum-Cost Solar Rooftop AllocationOA · Seen Jul 2025
  • Pair Elements with Even SumsOA · Seen Jul 2025
  • Count Divisible PermutationsOA · Seen Jan 2025
  • Largest Element in an ArrayOA · Seen Nov 2024
  • Install Carbon FiltersOA · Seen Oct 2023
  • Longest Substring with Even OccurrencesOA · Seen Oct 2023
  • Maximum Sum RectangleOA · Seen Apr 2022

Similar questions at other companies

  • Second Highest SalaryPaytm · PHONE SCREENPaytm interview questions
  • Employees Who Earn More Than Their ManagersNykaa · PHONE SCREENNykaa interview questions
  • Employees Who Joined More Than a Week AgoNewgen Software · PHONE SCREEN
  • Departments Without EmployeesDell Technologies · PHONE SCREENDell Technologies interview questions
  • Second-Highest Distinct SalaryChubb · PHONE SCREENChubb interview questions
  • Swap Two Gender ValuesInfosys · PHONE SCREENInfosys interview questions
  • Find Rows Common to Two TablesSalesforce · PHONE SCREENSalesforce interview questions
  • Count Records Present in A but Not BCapital One · PHONE SCREENCapital One interview questions
  • Customer Order Count Distribution by CountryApple · PHONE SCREENApple interview questions
  • Employees Earning More Than Their ManagerMygate · PHONE SCREENMygate interview questions

Deloitte interview experiences

  • Deloitte New Grad Tech OA and Interview Questions: 14 Experiences
All Deloitte interview questionsSee Deloitte hiring insights