Interview Query

Employee Salaries (ETL Error)

23
Have you seen this question before?

Let’s say we have a table representing a company payroll schema.

Due to an ETL error, the employees table instead of updating the salaries every year when doing compensation adjustments, did an insert instead. The head of HR still needs the current salary of each employee.

Bonus: Write a query to get the current salary for each employee.

Note: Assume no duplicate combination of first and last names. (I.E. No two John Smiths)

Example:

Input:

employees table

Column Type
id VARCHAR
first_name VARCHAR
last_name VARCHAR
salary INTEGER
department_id INTEGER

Output:

Column Types
first_name VARCHAR
last_name VARCHAR
salary INTEGER
Next question: Drawing Random Variable
.....
MySQL 8.0.17
Loading editor
Use Shift + Enter to run query