FastPrepNth-Highest Distinct Salary Without Ranking Functions
Problems/Nth-Highest Distinct Salary Without Ranking Functions

Nth-Highest Distinct Salary Without Ranking Functions

Mastercard logoMastercard● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionConstraints

Problem statement

Source note: A firsthand report from a Mastercard Data Engineer onsite lists finding the Nth-highest salary without RANK or DENSE_RANK. We chose the parameter table, the rule that salaries are distinct, and what to return when there is no answer. Our version is about 94% the same as the reported question.

Return the Nth-highest distinct salary without using ranking window functions such as RANK, DENSE_RANK, or ROW_NUMBER.

The desired positive integer N is supplied in query_params.

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.

employees

ColumnTypeNullableDescription
employee_idPKIntegerNo—
employee_nameTextNo—
salaryDecimalNo—

query_params

Contains exactly one row with param_id 1.

ColumnTypeNullableDescription
param_idPKIntegerNo—
nIntegerNo—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
salaryDecimalNo—

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

Constraints

  • query_params contains exactly one row with param_id = 1 and positive n.
  • Duplicate salary values occupy one position.
  • Return no rows when fewer than N distinct salaries exist.

More Mastercard interview questions

  • Top Three Accounts by Monthly Transaction AmountPHONE SCREEN · Seen Sep 2026
  • Deduplicate a List While Preserving OrderPHONE SCREEN · Seen Jul 2026
  • Employee With the Highest SalaryPHONE SCREEN · Seen Jul 2026
  • Group Names by DepartmentPHONE SCREEN · Seen Jul 2026
  • Credit and Debit Transaction Counts per UserPHONE SCREEN · Seen Apr 2026
  • Users with Three Transactions in Sixty SecondsPHONE SCREEN · Seen Apr 2026
  • Container With Most WaterPHONE SCREEN · Seen Oct 2025
  • Employees with the Highest and Lowest SalaryPHONE SCREEN · Seen Apr 2025
  • Inactive Customers with Prior ActivityPHONE SCREEN · Seen Nov 2024
  • Merchant Category Transaction SummaryPHONE SCREEN · Seen Nov 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
  • Order Book Data ValidationJane Street · ONSITE INTERVIEWJane Street 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
  • Third-Highest Distinct SalaryExpedia · ONSITE INTERVIEWExpedia interview questions

Mastercard interview experiences

  • Mastercard Data Science Intern Interviews: 10 Experiences
All Mastercard interview questionsSee Mastercard hiring insights