select tag,t4.ct,t2.ct,concat(round((t2.ct/t4.ct-1)*100,1),'%') as rate,
       t4.rct,t2.rct,cast(t2.rct as signed)-cast(t4.rct as signed) as rk
from 
(select *,
      rank()over(order by ct desc) as rct
from 
    (select exam_id,count(submit_time) ct
    from exam_record
    where submit_time is not null
    and date(submit_time) between '2021-01-01' and '2021-06-30'
    group by exam_id
    ) t1
 ) t2
join 
(select *,
      rank()over(order by ct desc) as rct
from 
    (select exam_id,count(submit_time) ct
    from exam_record
    where submit_time is not null
    and date(submit_time) between '2020-01-01' and '2020-06-30'
    group by exam_id
    ) t3
 ) t4
on t2.exam_id=t4.exam_id
join examination_info
on t2.exam_id=examination_info.exam_id
order by rate desc,t2.rct desc;