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 9b413c2 commit 14e106cCopy full SHA for 14e106c
README.md
@@ -533,4 +533,15 @@ UNION
533
SELECT 'High Salary' AS category, SUM(IF(income>50000,1,0)) AS accounts_count
534
FROM Accounts
535
```
536
-
+[626. Exchange Seats](https://leetcode.com/problems/exchange-seats/)
537
+```sql
538
+-- id, student
539
+-- swap every two consecutives
540
+-- num(students): odd? no swap for last one
541
+
542
+SELECT id,
543
+CASE WHEN MOD(id,2)=0 THEN (LAG(student) OVER (ORDER BY id))
544
+ELSE (LEAD(student, 1, student) OVER (ORDER BY id))
545
+END AS 'Student'
546
+FROM Seat
547
+```
0 commit comments