SQL Gaps And Islands

Guides the canonical "gaps and islands" pattern family — detecting unbroken runs of consecutive values (islands — active streaks, sessions, contiguous date/number ranges) and the missing stretches between them (gaps) — with the portable set-based solution instead of brittle self-joins or procedural row-by-row loops. Auto-invokes when writing or editing queries for consecutive sequences, streaks/runs, longest-active-streak, sessionization, collapsing or merging adjacent date/number ranges, finding missing IDs/dates, or "group consecutive rows" / "find gaps" / "count consecutive days" requests.

ctoth 604b403 3 files · 33.0 KB Updated

File contents

ctoth/sql-skills-plugin/tree/main/plugins/sql/skills/sql-gaps-and-islands commit 604b403cad

Frequently asked questions

npx skillmds@latest add ctoth/sql-gaps-and-islands