break on BTIME select btime, event, round((time_ms_end-time_ms_beg)/nullif(count_end-count_beg,0),3) avg_ms from ( select to_char(s.snap_time,'DD-MON-YY HH24:MI') btime, e.event, total_waits count_end, time_waited_micro/1000 time_ms_end, lag (e.time_waited_micro/1000) OVER(partition by e.event ORDER BY s.snap_id) time_ms_beg, lag (e.total_waits) OVER(partition by e.event ORDER BY s.snap_id) count_beg from STATS$SYSTEM_EVENT e, STATS$SNAPSHOT s where s.snap_id=e.snap_id-1 and e.event in ( 'db file sequential read', 'db file scattered read', 'direct path read', 'direct path read temp', 'direct path write', 'direct path write temp', 'log file sync', 'log file parallel write' ) and s.snap_id between &1 and &2 order by snap_time ) order by btime /