题解 | #给出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

全部评论

相关推荐

11-01 08:48
门头沟学院 C++
伤心的候选人在吵架:佬你不要的,能不能拿户口本证明过户给我。。球球了
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务