Difference between consecutive rows using multiple columns
Solution 1:
Provided end_date
and start_date
are timestamp
delay
will be an interval
.
select project_name, project_phase, start_date, end_date,
end_date - lead(start_date) OVER (PARTITION BY project_name ORDER BY start_date ) as delay
from projects