Here is an example function showing the maximum difference between a timestamp field in row for a given partition (the SQL dialect is old Oracle 11gR2):
cat fgreat.sql set line 232 SELECT process_running, run_number, exec_seq, exec_timestamp as station_time, lead(exec_timestamp) OVER (partition by run_number order by exec_timestamp) - exec_timestamp as time_to_next_row FROM benchmark where run_number=&1 order by time_to_next_row asc ; exit;
This blog had some examples that helped me: