FastPrepEmployees Who Earn More Than Their Managers

Employees Who Earn More Than Their Managers

Nykaa logoNykaa● EasyFULLTIMEPHONE SCREEN

Problem statement

The employees table has one row per employee, with their salary and the ID of their direct manager.

Return the employee_id and employee_name of every employee who earns more than their direct manager. Sort the rows by employee_id from smallest to largest.

  • A null manager_id means the employee has no manager, so they are left out.
  • An employee who earns exactly as much as their manager is left out.
  • Compare only with the direct manager, not with anyone higher up.
  • Two employees can have the same name. They are still different employees.

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

One row per employee and the ID of their direct manager.

ColumnTypeNullableDescription
employee_idPKIntegerNo—
employee_nameTextNo—
salaryIntegerNo—
manager_idIntegerYes—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
employee_idIntegerNo—
employee_nameTextNo—

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

Constraints

  • The table has at most 2000 rows.
  • employee_id is unique and between 1 and 10^9.
  • employee_name is non-empty text of at most 100 characters.
  • salary is an integer between 0 and 10^9.
  • Every non-null manager_id is the employee_id of another row. Nobody is their own manager, and the reporting lines have no cycles.

More Nykaa problems

See Nykaa hiring insights