select
to_char((to_date('2019-07-01', 'yyyy-mm-dd') + numtodsinterval(avg(begin_time_second), 'second')),'hh24:mi:ss') avg_begin_time,
to_char((to_date('2019-07-01', 'yyyy-mm-dd') + numtodsinterval(avg(end_time_second), 'second')),'hh24:mi:ss') avg_end_time
--2019-07-01 00:00:00 + numtodsinterval(平均數,'秒')轉換爲日期格式,而後再轉換爲 時間字符格式
from
(
select
--把上班時間換算爲秒
to_char(a.actontime, 'hh24') * 3600 +
to_char(a.actontime, 'mi') * 60 +
to_char(a.actontime, 'ss') as begin_time_second,
--把下班時間換算爲秒
to_char(a.actofftime, 'hh24') * 3600 +
to_char(a.actofftime, 'mi') * 60 +
to_char(a.actofftime, 'ss') as end_time_second
from empworkdate a
)date