Finding biggest increase in MySQL

Solution 1:

"Biggest increase in salary" is ambiguous. You have found the biggest difference between the highest and lowest salaries. That is a very reasonable interpretation of the question, but there are others.

For instance, someone might have started at a high salary and then been demoted, so their highest salary is the first. This suggests another reasonable interpretation: the absolute value of the difference between the most recent salary and the first salary. That is a bit trickier to calculate in MySQL.

Another interpretation is the biggest percentage increase. So, an increase from $50,000 to $60,000 would be considered "bigger" than one from $500,000 to $550,000, because the percentage is bigger. Of course, this could be applied to either biggest/smallest or latest/first.

Similar questions could also have an answer regarding the increase per year in the salary.

So, the question is ambiguous, but you have a perfectly reasonable interpretation and your query implements this. I would not call the column max, because it is more appropriately called diff.