FastPrepNth Highest Salary
Problems/Nth Highest Salary

Nth Highest Salary

Paytm logoPaytm● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionConstraints

Problem statement

Source note: In a Paytm SDE loop, the SQL questions included writing a query for the Nth highest salary.

The report gives no table, column names, or rule for repeated salaries or a missing answer. Here, n comes from a one-row query_params table, equal salaries count once, and the single result row holds NULL when there are fewer than n salaries.

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. The query_params table has exactly one row, with param_id = 1 and a positive integer n.

Write a query that returns the n-th highest distinct salary. Employees with the same salary count as one salary value, so n = 1 means the highest salary. Return exactly one row with one column named nth_highest_salary. If there are fewer than n 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—

query_params

Exactly one row, with param_id 1, holding n.

ColumnTypeNullableDescription
param_idPKIntegerNo—
nIntegerNo—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
nth_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.
  • employee has at most 1000 rows and may be empty.
  • query_params has exactly one row: param_id = 1 and 1 <= n <= 1000.

More Paytm interview questions

  • Second 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

  • Email Funnel: Opened Within a Day, Replied Within a WeekSuperhuman · PHONE SCREENSuperhuman interview questions
  • iPhone Model Sales Share by CountryApple · PHONE SCREENApple interview questions
  • Top Three Accounts by Monthly Transaction AmountMastercard · PHONE SCREENMastercard interview questions
  • In-Memory Database QueriesOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Top Three Sales per County and YearClickhouse · PHONE SCREEN
  • Block Type with the Most ChildrenNotion · PHONE SCREENNotion interview questions
  • Third-Highest Known SalaryAdobe · PHONE SCREENAdobe interview questions
  • Days Between Each User's Latest Two PostsZip · PHONE SCREENZip interview questions
  • Observed-User Percentage by AppMicrosoft · PHONE SCREENMicrosoft interview questions
  • Nth-Highest Book Sales VolumeAmazon · PHONE SCREEN
All Paytm interview questionsSee Paytm hiring insights