Third-Highest Distinct Salary
Updated
Problem statement
The employee table has one row per employee: a unique employee_id, the employee_name, and the employee's salary.
Find the third-highest different salary. Employees who earn the same amount count as one salary value. For example, if the salaries are 500, 500, 400 and 300, the third-highest different salary is 300.
Return exactly one row with one column named third_highest_salary. If there are fewer than three different 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.
| Column | Type | Nullable | Description |
|---|---|---|---|
| employee_idPK | Integer | No | — |
| employee_name | Text | No | — |
| salary | Integer | No | — |
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| third_highest_salary | Integer | Yes | — |
Row order: must match exactly. Numeric tolerance: 0.
Constraints
- The
employeetable has from0to1000rows. employee_idis unique and1 <= employee_id <= 10^6.0 <= salary <= 10^9, and salaries are whole numbers.employee_nameis one uppercase English letter followed by 0 to 19 lowercase English letters. Names can repeat.- No value is
NULL.
More Expedia Onsite Interview questions
- Scramble StringONSITE INTERVIEW · Seen Sep 2026
- Smallest Sufficient TeamONSITE INTERVIEW · Seen Sep 2026
- Check Anagram Pairs Index by IndexONSITE INTERVIEW · Seen Oct 2025
- Fresh Oranges Left After Rotting StopsONSITE INTERVIEW · Seen Oct 2025
- Longest Increasing SubsequenceONSITE INTERVIEW · Seen Oct 2025
- Lowest Common Ancestor with Repeated and Missing ValuesONSITE INTERVIEW · Seen Oct 2025
- Shortest Substring with Exactly K OnesONSITE INTERVIEW · Seen Oct 2025
- Middle Element of a Linked ListONSITE INTERVIEW · Seen Nov 2024
- Minimum in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Sep 2024
- Mirror Image Binary TreesONSITE INTERVIEW · Seen Sep 2024
Similar questions at other companies
- Daily USD Totals with Effective-Dated Exchange RatesMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Most Recent Order for Each CustomerCapgemini · ONSITE INTERVIEWCapgemini interview questions
- Tenth-Highest Distinct SalaryInfosys · ONSITE INTERVIEWInfosys interview questions
- Fifth Highest Salary In A DepartmentZS · ONSITE INTERVIEWZS interview questions
- In-Memory Database QueriesOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
- Nth-Highest Distinct Salary Without Ranking FunctionsMastercard · ONSITE INTERVIEWMastercard interview questions
- Contest Participants with Long Totals and Short QuestionsThe Walt Disney Company · ONSITE INTERVIEWThe Walt Disney Company interview questions
- First Order per Merchant per DateAmazon · ONSITE INTERVIEW
- Block Transaction Count TrendsChainalysis · ONSITE INTERVIEWChainalysis interview questions
- Highest-Paid Employees in Every DepartmentMorgan Stanley · ONSITE INTERVIEWMorgan Stanley interview questions
Interview reports that mention this question
Expedia interview experiences
- Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
- Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
- Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
- Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)
- Expedia SWE Intern Final Round: 126 Experiences (Part 1 of 6)