题解 | #大小写混乱时的筛选统计#

大小写混乱时的筛选统计

https://www.nowcoder.com/practice/81cb12931a604811ae69d332515c7734

with a as
#   先计算所有带大小写字母的tag的作答数,存临时表a
(select  tag,count(start_time) answer_cnt
from exam_record er
join examination_info ei on ei.exam_id=er.exam_id
where tag REGEXP '[a-zA-Z]'
group by tag),
# 计算所有带大小写字母的tag的作答数小于3的数,存临时表b
b as(
select tag,count(start_time) answer_cnt
from exam_record er
join examination_info ei on ei.exam_id=er.exam_id
where tag REGEXP '[a-zA-Z]'
group by tag
having answer_cnt<3)
#  2张表自连接,取小写字母做tag,然后取大写字母对应的作答数,
select b.tag tag,a.answer_cnt answer_cnt
 from a,b where a.tag<>b.tag and upper(b.tag)=a.tag

全部评论

相关推荐

10-14 21:00
门头沟学院 Java
吃花椒的狸猫:这个人说的倒是实话,特别是小公司,一个实习生哪里来的那么多要求
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务