题解 | #大小写混乱时的筛选统计#
大小写混乱时的筛选统计
http://www.nowcoder.com/practice/81cb12931a604811ae69d332515c7734
with q as
(select
tag,
count(start_time) as answer_cnt
from exam_record er right join examination_info ei
on er.exam_id = ei.exam_id
where start_time is not null
group by tag),
qq as
(
select
tag
from exam_record er right join examination_info ei
on er.exam_id = ei.exam_id
where start_time is not null
group by tag
having count(start_time)<3
)
select qq.tag, q.answer_cnt
from q,qq
where q.tag = upper(qq.tag) and q.tag != qq.tag;#如果转换后tag并没有发生变化,不输出该条结果。