考虑到后面输出的顺序不变,所以最终查找是在原表中,然后在满足条件的基础上输出结果。
1、考虑到会涉及排名,首先可以想到使用开窗,此处使用row_number

select
  first_name,
  row_number() over(order by first_name) as ranking
from employees

2、在排名中选择ranking为奇数的项

select
  first_name
from (
      select
        first_name,
        row_number() over(order by first_name) as ranking
      from employees
      ) as t
where t.ranking & 1  # 也可以使用 where t.ranking % 2 = 1

3、以2作为筛选条件,从employees表中选出结果

select
      first_name
from employees
where first_name in (
                     select
                       first_name
                     from (
                           select
                             first_name,
                             row_number() over(order by first_name) as ranking
                           from employees
                        ) as t
                  where t.ranking & 1)