FastPrepThird-Highest Distinct Salary
Problems/Third-Highest Distinct Salary

Third-Highest Distinct Salary

Expedia logoExpedia● MediumINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionConstraints

Problem statement

Source note: One question in a 2021 Expedia campus interview for SDE interns was a SQL query on an employee table that picks out the salary ranked third from the top.

The report does not say whether equal salaries count once, what to return when there is no third salary, or the output shape. Here, equal salaries count once. The answer is always one row with one column, third_highest_salary. That row holds NULL when there are fewer than three different salaries. A salary of 0 is a real value.

Our version is about 90% the same as the reported question.

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.

ColumnTypeNullableDescription
employee_idPKIntegerNo—
employee_nameTextNo—
salaryIntegerNo—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
third_highest_salaryIntegerYes—

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

Constraints

  • The employee table has from 0 to 1000 rows.
  • employee_id is unique and 1 <= employee_id <= 10^6.
  • 0 <= salary <= 10^9, and salaries are whole numbers.
  • employee_name is 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 Intern Final Round in 2021: 28 Experiences (Part 4 of 6)

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)
All Expedia interview questionsSee Expedia hiring insights