here's a cool problem someone asked about, I tried to be lazy and have Claude do it but Claude couldn't figure it out, except it was nice enough to show me the LAG and LEAD window functions.
Select a bunch of objects, and each has a link to its "previous" and "next" entry in order of table insertion.
https://github.com/sqlalchemy/sqlalchemy/discussions/13027#discussioncomment-15225227