Top 10 highest paid employees, not contracts
In The Dossier's question, it has been clarified that the result we get was only the top 10 highest paid contracts. It really bothered me create the result that should have been - to get the 10 highest paid employees. That would mean a list of the top salaries but only contains the maximum salary received by each employee. That way, each emp_no would appear once in that list.
After a few digging on the internet, this is what I have came up with:
SELECT * FROM salaries WHERE salary IN (SELECT MAX(salary) FROM salaries GROUP BY emp_no) ORDER BY salary DESC LIMIT 10;
I would appreciate your help in checking my work.
It seems that I can pull the same result with this simpler command:
SELECT emp_no, MAX(salary) AS salary, from_date, to_date FROM salaries GROUP BY emp_no ORDER BY MAX(salary) DESC LIMIT 10;