Urgent.News

What's breaking now, across thousands of outlets.

More in Tech

Solving the Classic SQL "Gaps and Islands" Problem: 3 Modern Approaches

If you've ever needed to find consecutive streaks in data — days a user logged in back to back, uninterrupted stretches of sensor readings, runs of matching status codes — you've run into the "gaps…

  • Approach 1 uses row-number trick to create group IDs by subtracting row numbers from dates
  • Approach 3 directly matches boundaries using LAG() and LEAD() to find streak start and end dates

More from Tuesday 15 September →