Hi, I have a table with the following two columns:

create table tab1 (col1 varchar2(10), col2 timestamp)

I need to calculate the difference (time gap) between the columns and return the grand total at the end, I am using the LAG function to return the time gap

select col1, to_char(col2,'HH24:MI:SS') step_time, TO_CHAR(col2-LAG(col2,1,null) over (ORDER BY col2),'HH24:MI:SS.FF') time_gap
from tab1
order by col2;

But how to get the grant total of the time gap like the following?

step1 18:41:00
step2 18:41:17 00:00:17.710289
step3 18:41:19 00:00:02.022712
step4 18:54:50 00:13:30.757169
total time 00:13:50



I tried to use rollup function but no success. Please help. Thanks