Nth Highest Salary
Updated
Problem statement
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
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.
| Column | Type | Nullable | Description |
|---|---|---|---|
| idPK | Integer | No | — |
| salary | Integer | No | — |
query_params
Exactly one row, with param_id 1, holding n.
| Column | Type | Nullable | Description |
|---|---|---|---|
| param_idPK | Integer | No | — |
| n | Integer | No | — |
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| nth_highest_salary | Integer | Yes | — |
Row order: must match exactly. Numeric tolerance: 0.
Constraints
idis a unique integer between1and10^9.0 <= salary <= 10^6, and no value is null.employeehas at most1000rows and may be empty.query_paramshas exactly one row:param_id = 1and1 <= 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