Skip to content

Commit af4f7a0

Browse files
Create 626. Exchange Seats
1 parent 4397687 commit af4f7a0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

sql/medium/626. Exchange Seats

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* MS SQL */
2+
3+
SELECT CASE
4+
WHEN id % 2 <> 0 AND id = (SELECT COUNT(*)
5+
FROM seat)
6+
THEN id
7+
WHEN id % 2 = 0
8+
THEN id - 1
9+
ELSE id + 1
10+
END AS id,
11+
student
12+
FROM Seat
13+
ORDER BY id

0 commit comments

Comments
 (0)