FastPrepSecond Highest Salary
Problems/Second Highest Salary

Second Highest Salary

Paytm logoPaytm● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionConstraints

Problem statement

Source note: In a Paytm SDE loop, the SQL questions included finding the second highest salary, right after an Nth highest salary query.

The report gives no table, column names, or rule for repeated salaries or a missing answer. 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 returns the second highest distinct salary. Employees with the same salary 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 integer between 1 and 10^9.
  • 0 <= salary <= 10^6, and no value is null.
  • The table has at most 1000 rows and may be empty.

More Paytm interview questions

  • Nth Highest SalaryPHONE SCREEN · Seen Nov 2026
  • Jump GamePHONE SCREEN · Seen Nov 2026
  • LRU Cache with Expiring EntriesPHONE SCREEN · Seen Sep 2026
  • Detect a Linked-List CycleONSITE INTERVIEW · Seen Sep 2026
  • Find First and Last Position in Sorted ArrayONSITE INTERVIEW · Seen Sep 2026
  • Minimum Coins for a TargetONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

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