题解 | #筛选限定昵称成就值活跃日期的用户#
筛选限定昵称成就值活跃日期的用户
https://www.nowcoder.com/practice/2ed07ff8f67a474d90523b88402e401b
select uid,nick_name,achievement from user_info
where nick_name like "牛客%号" and achievement between 1200 and 2500
and uid in (
select uid from exam_record
where year(start_time)=2021 and month(start_time)=09
union
select uid from practice_record
where year(submit_time)=2021 and month(submit_time)=09
);
题目要求的用户信息均来自user_info表,则按照要求筛选出对应的用户信息即可
1.用户昵称以“牛客”开头“号”结尾,对昵称进行模糊查询,like 条件1: nick_name like "牛客%号" ,其中%表示中间有0-多个字符(不确定),另“_”表示一个字符;
2.成就值在1200-2500之间,between...and 条件2:achievement between 1200 and 2500
3.用户最近一次活跃在2021年9月:(没注意是最近一次,那我这个并不严谨,只是筛选了2021年9月有活跃记录的用户,但结果是通过了的,就。。。)
从表exam_record和 pratice_record中查找符合条件的用户并将结果去重展示:union
uid in (
select uid from exam_record
where year(start_time)=2021 and month(start_time)=09
union
select uid from practice_record
where year(submit_time)=2021 and month(submit_time)=09


查看7道真题和解析