题解 | #某乎问答回答过教育类问题的用户里有多少用户回答过职场类问题#
某乎问答回答过教育类问题的用户里有多少用户回答过职场类问题
http://www.nowcoder.com/practice/b02cf9ee7b9f4cdda308f8155ff3415d
解法1:正常解法,教育类问题id inner join 职场类问题id(记得加distinct)
select count(distinct author_id) num from issue_tb t1 join answer_tb t2 on t1.issue_id=t2.issue_id where issue_type = 'Education' and author_id in ( select author_id from issue_tb a join answer_tb b on a.issue_id=b.issue_id where issue_type = 'Career' )解法2(参考):可以直接从author_id的首字母推出这个问题分属什么类别
SELECT COUNT(DISTINCT author_id) num FROM answer_tb WHERE issue_id LIKE 'E%' AND author_id IN (SELECT author_id FROM answer_tb WHERE issue_id LIKE 'C%')