题解|RLIKE正则表达式|筛选昵称规则和试卷规则的作答记录
筛选昵称规则和试卷规则的作答记录
https://www.nowcoder.com/practice/1c5075503ccf4de1882976b2fff2c072
## 用户信息表user_info,信息表examination_info,作答记录表exam_record ### SELECT * FROM user_info, examination_info, exam_record, avg_score, nick_name ## 昵称是'^牛客[0-9]+号$' OR '^[0-9]+$' ## 试卷类别是tag LIKE '^[Cc]' ## 已完成的试卷:submit_time IS NOT NULL或者写成 score IS NOT NULL ## SELECT a.uid,a.exam_id,ROUND(AVG(score),0) AS avg_score FROM exam_record a LEFT JOIN examination_info b ON a.exam_id = b.exam_id LEFT JOIN user_info c ON a.uid = c.uid WHERE (c.nick_name RLIKE '^牛客[0-9]+号$' OR c.nick_name RLIKE '^[0-9]+$') AND b.tag RLIKE '^[Cc]' AND a.score IS NOT NULL GROUP BY a.uid,exam_id ORDER BY a.uid,avg_score