here is the query involving a join and two tables (if you want min, remove desc, if you want max, put desc after order by)
select * from (
select A.key1, B.key2, rank() over (partition by key1 order by key2) rn, B.starttime
from table1 A, table2 B
where A.key1=B.key1
) x where rn=1
above gives you min key2 for each key1