题解 | #给出employees表中排名为奇数行#
给出employees表中排名为奇数行的first_name
https://www.nowcoder.com/practice/e3cf1171f6cc426bac85fd4ffa786594
SELECT first_name FROM employees JOIN( SELECT first_name, ROW_NUMBER() OVER(ORDER BY first_name) r_num FROM employees ) t USING(first_name) WHERE r_num % 2 = 1
1、新建一张表,对姓名进行排序
SELECT first_name, ROW_NUMBER() OVER(ORDER BY first_name) r_num FROM employees
2、取奇数行的姓名
SELECT first_name FROM employees JOIN( SELECT first_name, ROW_NUMBER() OVER(ORDER BY first_name) r_num FROM employees ) t USING(first_name) WHERE r_num % 2 = 1