试卷作答记录表exam_record中,表已建好,其结构如下,请用一条语句将这两条记录插入表中。
insert into exam_record(uid,exam_id,start_time,submit_time,score) values(1001,9001,'2021-09-01 22:11:12','2021-09-01 23:01:12',90),(1002,9002,'2021-09-04 07:01:02','2021-09-04 07:11:02',null);
现有一张试卷作答记录表exam_record,结构如下表,其中包含多年来的用户作答试卷记录,由于数据越来越多,维护难度越来越大,需要对数据表内容做精简,历史数据做备份。
表exam_record:
insert into exam_record_before_2021
select null,uid,exam_id,start_time,submit_time,score from exam_record
where year(submit_time)<2021;
试题信息表examination_info:
replace into examination_info value(null,9003,'SQL','hard',90,'2021-01-01 00:00:00');
请你帮她从exam_record数据表中计算所有用户完成SQL类别高难度试卷得分的截断平均值(去掉一个最大值和一个最小值后的平均值)。
示例数据:examination_info(exam_id试卷ID, tag试卷类别, difficulty试卷难度, duration考试时长, release_time发布时间)
示例数据:exam_record(uid用户ID, exam_id试卷ID, start_time开始作答时间, submit_time交卷时间, score得分)
根据输入你的查询结果如下:
从examination_info表可知,试卷9001为高难度SQL试卷,该试卷被作答的得分有[80,81,84,90,50],去除最高分和最低分后为[80,81,84],平均分为81.6666667,保留一位小数后为81.7
select
tag,
difficulty,
ROUND((sum(score)-max(score)-min(score))/(COUNT(score)-2),1) clip_avg_score
from
examination_info
JOIN
exam_record
using(exam_id)
where tag='SQL' and difficulty='hard';