Here is the second SQL example that took me more googling than it should have so I thought I’d also post about it. Lets assume we have a SQL table with employee bonuses in it. We know how easy it is to find the highest bonus.

SELECT max(emp_bonus) FROM employeetable

Or the smallest bonus.

SELECT min(emp_bonus) FROM employeetable

However, what if we want to know what the 8th highest bonus was? It turns out it is a lot easier than it seemed (at least to me.)

SELECT min(emp_bonus) FROM employeetable
WHERE emp_bonus IN
(SELECT distinct top 8 emp_bonus FROM employeetable order by emp_bonus desc)

If we wanted the 120th highest bonus we would just make it the top 120.