select difficult_level, sum(right_answ_num) / sum(answ_num) as correct_rate from ( select a.device_id, b.question_id, d.difficult_level, coalesce(b.answ_num, 0) as answ_num, coalesce(c.right_answ_num, 0) as right_answ_nu...