问题一:活动7天,每人每天有3次机会,每次机会答5道题,每5道题一个批次,答对有状态status为Y。现在需要获取活动期间每天都答题正确的人
-- ****-小小野猪
select user_id
from (
select user_id,
to_char(create_time, 'yyyy-mm-dd') as day,
count(distinct question_id) as batch_count
from t_question_record
where status = 'true'
group by user_id, to_char(create_time, 'yyyy-mm-dd')
) t
group by user_id
having count(day) = 7 and min(batch_count) = 3
这个查询将返回在活动期间每日至少有一次答题全对的所有用户的ID及其对应日期。