select extract (epoch from CASE when details -> 'sla' ->> 'slaStopped' is null THEN now()::timestamp else (details -> 'sla' ->> 'slaStopped')::timestamp end) - CASE when details -> 'sla' ->> 'ksSla' is null THEN '0'::integer else (details -> 'sla' ->> 'ksSla')::integer end * 60 - extract(epoch from start_time) as of_Details_Ks_Sla_plus_start_time from trouble_tickets where id in (148341, 150356, 139280, 148106, 149863);