with t1 as
(
    select 
    emp_id,
    exam_id,
    score,
    AVG(score) over(partition by exam_id) as avg_sco,
    timestampdiff(second, start_time, submit_time) as all_time,
    AVG(timestampdiff(second, start_time, submit_time)) over(partition by exam_id) as avg_time
    from 
    exam_record
)
,
t3 as
(
select * from t1 where score > avg_sco and all_time < avg_time
)

select 
emp_info.emp_id,
emp_level,
tag
from 
t3 
left join emp_info on t3.emp_id = emp_info.emp_id
left join examination_info on t3.exam_id = examination_info.exam_id
where emp_level < 7