我觉得理解一下这句话“回答过教育类问题的用户里有多少用户回答过职场类问题”,无论是正向集合筛选逻辑还是反向集合筛选逻辑都可以,那这么理解就更好理解了,相当于两个韦恩图的交集嘛,那直接分组计算不就得了:
- 即回答过教育且回答了职场的用户数量(筛选回答教育或职场问题类型后,分用户组、回答问题的类型数>=2)
select count(distinct author_id) as num from ( select author_id, count(distinct issue_type) as answer_type_num from issue_tb as At1 left join answer_tb as At2 using(issue_id) where issue_type in ("Education","Career") group by author_id having answer_type_num>=2 ) as t1