题解 | SQL260 给出employees表中排名为奇数行的first_name

WITH t1 AS (
	SELECT
    	first_name,
    	ROW_NUMBER() OVER(ORDER BY first_name ASC) AS ranking
    FROM employees
),
t2 AS (
	SELECT
    	first_name
    FROM t1
    WHERE ranking % 2 = 1
),
t3 AS (
    SELECT 
    	first_name 
    FROM employees
    WHERE first_name 
    IN (SELECT first_name FROM t2)
)
SELECT * FROM t3;
# 注意是按照原顺序返回!

全部评论

相关推荐

不愿透露姓名的神秘牛友
2024-12-16 18:14
腾讯 后端 31×15 本科985
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务