A failed release still consumes runner time. WHERE selects the runs to include, then SUM adds their recorded durations. A missing measurement contributes no seconds to the sum.
SELECT SUM(duration_seconds) AS staging_seconds
FROM deployments
WHERE environment = 'staging';Find the total recorded duration_seconds for runs in production with status failed. Return it as total_seconds.