SQLQuokka
Start practicing
QuestionsLearnSandboxFeaturesRoadmapFAQ

Swap Adjacent Seats

Unsolved

A teacher wants to swap every pair of neighboring students: seat 1 with seat 2, seat 3 with seat 4, and so on. Seat ids run from 1 with no gaps. If the number of students is odd, the student in the last seat stays where they are. Write an SQL query that returns id and student after the swap. Order the results by id ascending.

SQL Query Editor (Ctrl+Enter to run)
0 characters · Valid
Canonical Solution Official

Official Solution is Hidden

Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.

Community Q&A & Discussion

Ask questions, share alternate queries, and explore solutions

0 comments
Asked By:
Classic pattern · not tied to a specific company

Submission History

Your recent query executions and answer checks

Execution Pipeline:
FROM seat
Full source dataset
5 rows total
Ready. Type a query to see live execution.
Clause: Auto-Sync · AlaSQL Engine