Use desktop for interactive SQL sandbox
Tip: Press Alt+Enter to run SQL

SQL Output

sql-gaps-and-islands-problem
Public
Master the gaps-and-islands pattern, one of SQL's most versatile techniques for analyzing time-series data. This tutorial demonstrates how to identify continuous periods (islands) and breaks (gaps) in overlapping events, from hotel booking clusters to network alarm sequences. Learn to use window functions like LAG() and running sums with CTEs to solve real-world problems in network monitoring, user session analysis, server uptime tracking, and equipment maintenance scheduling. Includes complete working examples you can run immediately in PostgreSQL or MySQL.
jrz1977
PostgreSQL
Created Jan 10, 2026
Updated Jan 30, 2026
1Notes Notes
2SQL SQL
1 SQL 1 Notes
Switch to a SQL tab and press Alt+Enter to run queries
sql-gaps-and-islands-problem Updated 1/30/26, 2:23 AM
Notes SQL
Alt+Enter to run