Which device installation had the longest streak of successful deployments on consecutive calendar days? Count multiple successful events for the same installation on the same date as one day.
For ties, choose the installation with the smaller device_id, then the streak with the earlier start.
Columns: device_id, device_name, streak_start, streak_end, consecutive_days
Output order: any.
The query runs in a browser against PostgreSQL 17.
Starting PostgreSQL…
Starting PostgreSQL…