Published on

Leetcode - 626. Exchange Seats

Authors
  • avatar
    Name
    Indo Yoon
    Twitter
Table of Contents

문제

[Loading...

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

LeetCode

](https://leetcode.com/problems/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