select e1.first_name from employees e1
where
(
select count(*) from employees e2 where
e1.first_name>=e2.first_name
)%2 = 1

其实这里主要的理解清楚 e1.first_name>=e2.first_name,同样都是字符串怎么比较呢?
比如 select 'a' > 'b' 。可能会看不出来谁大谁小,怎么比较的呢?其实字符串内部是通过转换成 ascii 编码来进行大小比较的。
如 我们 查询 select ascii('a') , asc('b') 会得到 65 与 66。所以 select 'a' > 'b' 返回 0 。
那么再回到原题 e1.first_name>=e2.first_name

直接说可能不会懂 放两段代码
第一段: select e2.first_name,( select count(*) from employees as e1 where e1.first_name <= e2.first_name ) as rownum
from employees as e2
第二段: select e1.first_name,ascii(e1.first_name),row_number() over(order by first_name)
from employees e1 ;(mysql8 已经内置了窗体函数。)

(不明白的小伙伴可以看看:
row_number(): 同薪不同名,相当于行号,例如3000、2000、2000、1000排名后为1、2、3、4
rank(): 同薪同名,有跳级,例如3000、2000、2000、1000排名后为1、2、2、4
dense_rank(): 同薪同名,无跳级,例如3000、2000、2000、1000排名后为1、2、2、3
ntile(): 分桶排名,即首先按桶的个数分出第一二三桶,然后各桶内从1排名,实际不是很常用
partition by,按某字段切分
order by,与常规order by用法一致,也区分ASC(默认)和DESC,因为排名总得有个依据

作者:luanhz
链接:https://leetcode-cn.com/problems/nth-highest-salary/solution/mysql-zi-ding-yi-bian-liang-by-luanz/

相互比较一下就能出来了。然后也就得到奇数了。那么接下来的 %2 = 1 这个取得奇数。