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

Second-Highest Distinct Salary

Infosys logoInfosys● EasyFULLTIMEPHONE SCREEN

Updated Sep 2026

QuestionConstraints

Problem statement

Source note: An interview report named the second-highest-salary query. This exercise defines the table schema, distinct ranking, and result for fewer than two distinct salaries.

The table employees contains one row per employee with an integer salary. Find the second-highest distinct salary.

Return exactly one row with the column second_highest_salary. If fewer than two distinct salaries exist, return NULL in that row.

Table: employees

ColumnTypeMeaning
employee_idintegerUnique employee identifier
salaryintegerEmployee salary

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—
salaryIntegerNo—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
second_highest_salaryIntegerYes—

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

Constraints

  • The table may be empty.
  • employee_id is unique and non-null.
  • salary is non-null and is between -10^9 and 10^9.
  • Equal salaries share a rank.

More Infosys interview questions

  • Swap Two Gender ValuesPHONE SCREEN · Seen Oct 2026
  • At Most K Jumps with Quadratic Transition CostOA · Seen Nov 2026
  • Hiking Club Fastest PaceOA · Seen Nov 2026
  • Lowest Common Ancestor with a Changing RootOA · Seen Nov 2026
  • Minimum Coins for a TargetONSITE INTERVIEW · Seen Nov 2026
  • Minimum Leaf Path Sum over All RootsOA · Seen Nov 2026
  • Split Array to Minimize the Largest SumOA · Seen Nov 2026
  • Cherry PickupOA · Seen Nov 2026
  • Delete Duplicate Employee RecordsONSITE INTERVIEW · Seen Nov 2026
  • Find Duplicate Employee RecordsONSITE INTERVIEW · Seen Nov 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
  • Second-Highest Distinct SalaryChubb · PHONE SCREENChubb 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 Infosys interview questionsSee Infosys hiring insights