没个十年脑血栓写不出这种题干,明明意思是必须按照原表顺序输出,结果写成输出不需要排序。
所以这道题首先在子查询里选出first_name并根据first_name进行标号,然后将原表employees和子查询根据first_name连接并限制标号为奇数,也就是ranking % 2 = 1。最后从原表employees中选出first_name。
select s.first_name from employees as s,
(select first_name, row_number() over (order by first_name) as ranking
from employees) as temp
where s.first_name = temp.first_name and temp.ranking % 2 = 1