Leetcode - 626. Exchange Seats
문제
정답
SELECT
CASE
WHEN id = len AND id % 2 = 1 THEN id
WHEN id % 2 = 1 THEN id + 1
ELSE id - 1
END AS id, student
FROM Seat, (
SELECT COUNT(*) AS len
FROM Seat
) AS NewSeat
ORDER BY id
SELECT
CASE
WHEN id = len AND id % 2 = 1 THEN id
WHEN id % 2 = 1 THEN id + 1
ELSE id - 1
END AS id, student
FROM Seat, (
SELECT COUNT(*) AS len
FROM Seat
) AS NewSeat
ORDER BY id