select uid, exam_id, round(avg(score),0) as avg_score
from exam_record
where uid in (select uid from user_info
where nick_name rlike '^牛客[0-9]+号$' or nick_name rlike '^[0-9]+$')
and exam_id in (select exam_id from examination_info
where tag rlike '^[cC]')
and score is not null
group by uid, exam_id 
order by uid, avg_score

rlike 常用的正则表达式模式:

  • .:匹配任意单个字符。
  • ^:匹配字符串的开始。
  • $:匹配字符串的结束。
  • *:匹配零个或多个前面的元素。
  • +:匹配一个或多个前面的元素。
  • ?:匹配零个或一个前面的元素。
  • [abc]:匹配字符集中的任意一个字符。
  • [^abc]:匹配除了字符集中的任意一个字符以外的字符。
  • [a-z]:匹配范围内的任意一个小写字母。
  • [0-9]:匹配一个数字字符。
  • \w:匹配一个字母数字字符(包括下划线)。
  • \s:匹配一个空白字符。