题解 | #大小写混乱时的筛选统计#
大小写混乱时的筛选统计
https://www.nowcoder.com/practice/81cb12931a604811ae69d332515c7734
用到了自连接!参考了大神的解法,妙啊
- 先把符合条件的tag和answer_cnt统计出来
- 自连接
这道题对于题目的理解清楚很重要。
with t_tag_count as (
select tag, count(uid) as answer_cnt
from exam_record
left join examination_info using(exam_id)
group by tag
)
select a.tag, b.answer_cnt
from t_tag_count as a
join t_tag_count as b
on UPPER(a.tag) = b.tag and a.tag != b.tag and a.answer_cnt < 3


查看5道真题和解析