select
low.tag,
up.answer_cnt
from
(
select
er.exam_id,
tag,
count(start_time) as answer_cnt
from
examination_info ei,
exam_record er
where
ei.exam_id = er.exam_id
group by
tag,
er.exam_id
having
answer_cnt < 3
and tag != upper(tag)
) low,
(
select
tag,
count(start_time) as answer_cnt
from
examination_info ei,
exam_record er
where
ei.exam_id = er.exam_id
group by
tag
) up
where upper(low.tag) = up.tag

京公网安备 11010502036488号