SQL140 未完成率top50%用户近三个月答卷情况
SQL140 未完成率top50%用户近三个月答卷情况
# 请统计SQL试卷上未完成率较高的50%用户(对所有用户的完成率进行排序,找出完成率排名小于等于 50% 的用户)中,
# 6级和7级用户在有试卷作答记录的近三个月中,每个月的答卷数目和完成数目。
# 按用户ID、月份升序排序。
withtemp1 as (selectuser_info.uid,count(if(submit_time is null, 1, null)) / count(*) as incomplete_ratefromexam_recordjoin user_info using (uid)whereexam_id in (selectexam_idfromexamination_infowheretag = 'SQL')group byuidorder byuid desc),temp2 as (selectuid,incomplete_rate,percent_rank() over (order byincomplete_rate desc) as prfromtemp1order bypr),temp3 as (selectuid,date_format(start_time, "%Y%m") as start_month,count(start_time) as total_cnt,count(submit_time) as complete_cntfromexam_recordjoin user_info using (uid)whereuid in (selectuidfromtemp2wherepr <= 0.5)and uid in (selectuidfromuser_infowherelevel in (6, 7))group byuid,date_format(start_time, "%Y%m"))
selectuid,start_month,total_cnt,complete_cnt
from(selectuid,start_month,total_cnt,complete_cnt,rank() over (partition byuidorder bystart_month desc) as rkfromtemp3) as t1
whererk <= 3
order byuid,start_month