8000 Update README.md · Atharv625/sql-50-leetcode@14e106c · GitHub
[go: up one dir, main page]

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

Lines changed: 12 additions & 1 deletion
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)
0