Finding the smallest salary difference
You're given the following table showing employees at a company and their respective salaries:
Given the above table, write a SQL query to return the employees with the closest absolute difference in salaries. If there is a tie (e.g. multiple employees have the same salary difference), then show the record with the lower sum of salaries.
You can view/query this table in an interactive SQL fiddle here.
Subscribe to premium account to see the solution.Get premium now