题解 | #筛选限定昵称成就值活跃日期的用户#
筛选限定昵称成就值活跃日期的用户
http://www.nowcoder.com/practice/2ed07ff8f67a474d90523b88402e401b
#先筛选出uid,其应满足最近一次试卷或练习在2021年9月,在从第一个表找其他满足条件的字段
select uid,nick_name,achievement
from user_info
where uid in
(
select uid
from exam_record
group by uid
having max(date_format(start_time,'%Y%m'))=202109
union
select uid
from practice_record
group by uid
having max(date_format(submit_time,'%Y%m'))=202109
)
and nick_name like '牛客%号'
and achievement between 1200 and 2500