题解 | 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;
# 注意是按照原顺序返回!
