Skip to content

Commit 14e106c

Browse files
committed
Update README.md
1 parent 9b413c2 commit 14e106c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

README.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -533,4 +533,15 @@ UNION
533533
SELECT 'High Salary' AS category, SUM(IF(income>50000,1,0)) AS accounts_count
534534
FROM Accounts
535535
```
536-
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

Comments
 (0)