数据来源:题目所需文件 CARD_ID(身份证)、TNAME(姓名) 、SCORES(分数)、OPENID(设备ID) 、INSERTTIME(提交成绩时间)
题目要求 分数>=60分视为考试通过,有一次通过即为考核通过
1)查询考核次数>=2次的人员考核情况,结果列输出姓名、考核次数、考核结果
2)OPENID重复的两个人都视为涉嫌抄袭,查询涉嫌抄袭的人员名单,结果列输出身份证、姓名
表结构:
CREATE TABLE sheet1
(tname
varchar(255) DEFAULT NULL,card_id
varchar(255) DEFAULT NULL,scores
varchar(255) DEFAULT NULL,open_id
varchar(255) DEFAULT NULL,inserttime
varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
表数据:
tname card_id scores open_id inserttime
林八 388908199609234545 22 oMKeGtxO 2021/9/1
李四 342908199209234509 78 oMKeGtxQ 2021/9/2
王五 35690819960923434 93 oMKeGtxA 2021/9/3
周六 372083199609234571 43 oMKeGtxB 2021/9/4
孙七 328920908199609234 78 oMKeGtxC 2021/9/5
张三 320908199609234571 65 oMKeGtxD 2021/9/6
赵九 356908199609234532 45 oMKeGtxE 2021/9/7
周六 372083199609234571 87 oMKeGtxC 2021/9/8
林八 388908199609234545 78 oMKeGtxO 2021/9/9
吴十 321308199609234543 45 oMKeGtxQ 2021/9/10
张三 320908199609234571 98 oMKeGtxD 2021/9/11
肖十一 365083199609234534 87 oMKeGtxC 2021/9/12
陈十二 85 oMKeGtxF 2021/9/13
1、select s1.tname 姓名,s2.num 考核次数,case when max(s1.scores) >= '60' then '考核通过' else '考核不通过' end as 考核结果
from sheet1 s1
right join (select tname,count(*) num from sheet1 group by tname having num >= 2 ) s2
on s1.tname = s2.tname
group by s1.tname,s2.num;
2、select distinct s1.card_id 身份证,s1.tname 姓名
from sheet1 s1
right join (select distinct tname,open_id from sheet1) s2
on s1.open_id = s2.open_id
and s1.tname <> s2.tname
where card_id is not null;