I have a table of trip section details which includes a trip ID, start time as an offset, and a duration for that section.
I need to extract the full trip duration by adding the highest offset to it's duration. I can't simply use sum() on the duation as that would not include standing time.
select stts_id, total from (select stts_id, stts_offset+stts_duration as total, row_number() over (partition by stts_id order by stts_offset desc) as rank from sts) s where rank = 1 order by stts_id;