FastPrepEmployees with the Highest and Lowest Salary

Employees with the Highest and Lowest Salary

Mastercard logoMastercard● MediumFULLTIMEPHONE SCREEN

Problem statement

Return every employee whose salary equals the company-wide maximum or minimum.

Join each worker to the supplied current title and add salary_type: Highest Salary for the maximum and Lowest Salary for the minimum.

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.

workers

ColumnTypeNullableDescription
worker_idPKIntegerNo—
first_nameTextNo—
last_nameTextNo—
salaryDecimalNo—
joining_dateDateNo—
departmentTextNo—

titles

ColumnTypeNullableDescription
worker_ref_idPKIntegerNo—
worker_titleTextNo—
affected_fromDateNo—

Foreign key: worker_ref_id → workers(worker_id)

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
worker_idIntegerNo—
first_nameTextNo—
last_nameTextNo—
salaryDecimalNo—
salary_typeTextNo—
worker_titleTextNo—
departmentTextNo—

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

Constraints

  • The data contains at least two distinct salary values.
  • Each worker has exactly one row in titles.
  • Return all ties, highest rows first, and worker IDs ascending within each group.

More Mastercard problems

See Mastercard hiring insights