select a.a,a.b from table a,table b
where abs(to_number(to_char(a.starttime,'ss'))-to_number(to_char(b.starttime,'ss')))<1 and to_char(a.starttime,'yyyymmdd,24hh'))=to_char(b.starttime,'yyyymmdd,24hh'))
union all
select b.a,b.b from table a,table b
where abs(to_number(to_char(a.starttime,'ss'))-to_number(to_char(b.starttime,'ss')))<1 and to_char(a.starttime,'yyyymmdd,24hh'))=to_char(b.starttime,'yyyymmdd,24hh'))