select uid,
       round(sum(if(score is not null,score,0))/count(1),0) as avg_score,
       round(sum(if(score is NULL,duration,timestampdiff(minute,start_time,submit_time)))/count(1),1) as avg_time_took
from exam_record t
join examination_info t1 on t.exam_id = t1.exam_id
where uid in (select uid from user_info where level = 0) and difficulty = 'hard'
group by uid