题解 | #筛选限定昵称成就值活跃日期的用户#

筛选限定昵称成就值活跃日期的用户

http://www.nowcoder.com/practice/2ed07ff8f67a474d90523b88402e401b

复杂程度不如之前那条中等题目

**题目的测试用例似乎并不是很严谨。下边的版本只是有在2021年9月活跃过的,但提交通过了**
select u.uid,nick_name,achievement	from  user_info u left join (
select uid,start_time from exam_record
union all 
select uid,submit_time from exam_record
union all 
select uid,submit_time from practice_record) a  #组合两张表,将时间汇总。
on u.uid=a.uid
where achievement between 1200 and 2500
and nick_name like '牛客%号'
and start_time like '2021-09%'
group by u.uid,nick_name

稍微调整下将条件移到having即可。
select u.uid,nick_name,achievement	from  user_info u left join (
select uid,start_time from exam_record
union all 
select uid,submit_time from exam_record
union all 
select uid,submit_time from practice_record) a 
on u.uid=a.uid
where achievement between 1200 and 2500
and nick_name like '牛客%号'

group by u.uid,nick_name
having max(start_time) like '2021-09%'
全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务