/*SELECT first_name FROM ( SELECT first_name, ROW_NUMBER() OVER (ORDER BY first_name) as row_num, ROW_NUMBER() OVER (ORDER BY emp_no) as original_order FROM employees ) as temp WHERE temp.row_num % 2 = 1 ORDER BY temp.original_order;*/ #之所以这样写是默认emp_no是默认升序排列的,但题目中没有明确说明,严谨来说如果emp_no不是默认升序的话这么写还是会打乱默认顺序 /*select t.first_name from(select first_name,emp_no,row_number()over(order by first_name) rn from employees) t where rn%2=1 order by t.emp_no*/ #我用这个代码验证了一下上述猜想,果然emp_no是默认升序,也就是说间接证明了如果不是默认升序这么写就不符合题目要求 select em.first_name from employees em left join (select first_name,row_number()over(order by first_name) rn from employees) t on em.first_name=t.first_name where t.rn%2=1 #这么写是一定满足题目要求保持表格原始顺序进行输出的