[LeetCode] 626. Exchange Seats
2022. 6. 9. 23:38ㆍSQL
SELECT new_id AS id
,student
FROM (SELECT CASE WHEN MOD(id,2)=1 AND id=(SELECT MAX(id) FROM seat) THEN id
WHEN MOD(id,2)=1 THEN (id+1)
WHEN MOD(id,2)=0 THEN (id-1)
END AS new_id,
student FROM seat) AS sub
ORDER BY new_id;
'SQL' 카테고리의 다른 글
[LeetCode] 627. Swap Salary (0) | 2022.10.25 |
---|---|
[LeetCode] 1965. Employees With Missing Information (0) | 2022.06.16 |
[LeetCode] 180. Consecutive Numbers (0) | 2022.06.09 |
[LeetCode] 1050. Actors and Directors Who Cooperated At Least Three Times (0) | 2022.06.09 |
[LeetCode] 197. Rising Temperature (0) | 2022.06.09 |