题解 | #筛选限定昵称成就值活跃日期的用户#
筛选限定昵称成就值活跃日期的用户
https://www.nowcoder.com/practice/2ed07ff8f67a474d90523b88402e401b
select ui.uid, nick_name, achievement from user_info ui left join exam_record er on ui.uid = er.uid left join practice_record pr on ui.uid = pr.uid where nick_name like '牛客%号' and achievement between 1200 and 2500 group by ui.uid having (max(pr.submit_time) is not null and max(er.start_time) is not null and date_format(if(max(pr.submit_time)<=max(er.start_time),max(er.start_time),max(pr.submit_time)),'%Y%m')='202109') or (max(pr.submit_time) is not null and max(er.start_time) is null and date_format(max(pr.submit_time),'%Y%m')='202109') or (max(pr.submit_time) is null and max(er.start_time) is not null and date_format(max(er.start_time),'%Y%m')='202109')
踩坑了,max(null)返回none,max(null)<=max(1)也返回none