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

Second-Highest Distinct Salary

Chubb logoChubb● EasyNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionConstraints

Problem statement

Source note: A report asks for a query that returns the second-highest salary. We chose the rest. Ranking is by distinct salary, and we set the table layout, what happens when there is no second salary, the shape and order of the output, the test data, and the languages you can use.

The employees table contains one row per employee with an optional salary.

Return exactly one row and one column named second_highest_salary. Its value is the second-highest distinct non-NULL salary. If fewer than two distinct non-NULL salaries exist, return 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.

employees

One row per employee.

ColumnTypeNullableDescription
employee_idPKIntegerNo—
salaryIntegerYes—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
second_highest_salaryIntegerYes—

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

Constraints

  • employee_id is a unique integer.
  • salary is an integer or NULL.
  • Duplicate salary values share the same rank.
  • The result always contains exactly one row.

More Chubb interview questions

  • Find the Unique Element Among PairsPHONE SCREEN · Seen Oct 2026
  • Reverse a Singly Linked ListPHONE SCREEN · Seen Oct 2026
  • Count Pairs with K Divisible Values in the IntervalOA · Seen Oct 2026
  • Index of the Maximum After Left RotationsOA · Seen Oct 2026
  • Maximize Revenue from Decreasing InventoryOA · Seen Oct 2026
  • Minimize the Maximum Array ElementOA · Seen Oct 2026
  • Minimum Distinct Prefix CostOA · Seen Oct 2026
  • Flat JSON Value DifferencesOA · Seen Sep 2026
  • Maximum Student-Teacher DistanceOA · Seen Sep 2026
  • Minimum Cost to Reach a Target WeightOA · Seen Sep 2026

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
  • 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
  • Classify Tree Nodes with SQLOracle · PHONE SCREENOracle interview questions
All Chubb interview questionsSee Chubb hiring insights