We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bcc48be commit 574fe8bCopy full SHA for 574fe8b
LeetCode SQL 50 Solution/626. Exchange Seats.sql
@@ -51,5 +51,15 @@ Output:
51
+----+---------+
52
Explanation:
53
Note that if the number of students is odd, there is no need to change the last one's seat.
54
+'''
55
56
+# MYSQL Query Accepted
57
58
+SELECT ( CASE
59
+ WHEN id%2 != 0 AND id != counts THEN id+1
60
+ WHEN id%2 != 0 AND id = counts THEN id
61
+ ELSE id-1
62
+ END) AS id, student
63
+FROM seat, (select count(*) as counts from seat)
64
+AS seat_counts
65
+ORDER BY id ASC
0 commit comments