SQL代码练习
统计每个学校各难度的用户平均刷题数
https://www.nowcoder.com/practice/5400df085a034f88b2e17941ab338ee8?tpId=199&tqId=1975675&ru=/exam/oj&qru=/ta/sql-quick-study/question-ranking&sourceUrl=%2Fexam%2Foj%3Fpage%3D1%26tab%3DSQL%25E7%25AF%2587%26topicId%3D199
select
university
,diffcult_level
,ROUND(count(diffcult_level)/count(DISTINCT device_id)*1,4)
from (select
university
,a.device_id
,question_id
,(case ltrim(rtrim(b.question_id))
when 111 then "haed"
when 117 then "esay"
when 113 then "esay"
when 115 then "esay"
else "medium"
end
) as diffcult_level
from user_profile a
inner join question_practice_detail b on a.device_id = b.device_id
) d
group by university,diffcult_level
俩个表能解决的问题系统,系统不认,就很无奈