Ecco la mia soluzione proposta:
DECLARE @MinDate AS DATETIME = (SELECT MIN(flight_date) FROM flights);
WITH cte
AS
(
SELECT
flight_date, DATEDIFF(DAY, @MinDate, flight_date) AS NoDays,
DATEDIFF(DAY, @MinDate, flight_date)/5 AS NoGroup,
DPT
FROM flights
)
SELECT
DATEADD(DAY, NoGroup*5, @MinDate) AS [Week Start],
DATEADD(DAY, NoGroup*5+4, @MinDate) AS [Weed End],
SUM(DPT)
FROM cte
GROUP BY NoGroup;
L'idea è di formare gruppi di 5 giorni, quindi associare un record a un gruppo specifico in base alla divisione con 5. NoDays rappresenta i giorni trascorsi da MinDate a Flight_Date.