<>分析

5天必须都做题，不然GG

SELECT info.user_id FROM ( SELECT two.user_id, sum( IF ( two.question_id IN (
SELECT DISTINCT one.question_id FROM log_table AS one WHERE one.date between
"2022-09-19" and "2022-09-22" AND one.user_id = two.user_id ), 0, 1 )) AS num
FROM log_table AS two WHERE two.date = "2022-09-23" GROUP BY two.user_id ) info
WHERE info.num >0
<>补充完善
select * from (SELECT info.user_id FROM ( SELECT two.user_id, sum( IF (
two.question_id IN ( SELECT DISTINCT one.question_id FROM log_table AS one
WHERE one.date between "2022-09-19" and "2022-09-22" AND one.user_id =
two.user_id ), 0, 1 )) AS num FROM log_table AS two WHERE two.date =
"2022-09-23" GROUP BY two.user_id ) info WHERE info.num >0) as d5 left join
(SELECT info.user_id FROM ( SELECT two.user_id, sum( IF ( two.question_id IN (
SELECT DISTINCT one.question_id FROM log_table AS one WHERE one.date between
"2022-09-19" and "2022-09-21" AND one.user_id = two.user_id ), 0, 1 )) AS num
FROM log_table AS two WHERE two.date = "2022-09-22" GROUP BY two.user_id ) info
WHERE info.num >0) as d4 on d5.user_id = d4.user_id left join (SELECT
info.user_id FROM ( SELECT two.user_id, sum( IF ( two.question_id IN ( SELECT
DISTINCT one.question_id FROM log_table AS one WHERE one.date between
"2022-09-19" and "2022-09-20" AND one.user_id = two.user_id ), 0, 1 )) AS num
FROM log_table AS two WHERE two.date = "2022-09-21" GROUP BY two.user_id ) info
WHERE info.num >0) as d3 on d5.user_id = d3.user_id left join (SELECT
info.user_id FROM ( SELECT two.user_id, sum( IF ( two.question_id IN ( SELECT
DISTINCT one.question_id FROM log_table AS one WHERE one.date between
"2022-09-19" and "2022-09-19" AND one.user_id = two.user_id ), 0, 1 )) AS num
FROM log_table AS two WHERE two.date = "2022-09-20" GROUP BY two.user_id ) info
WHERE info.num >0) as d2 on d5.user_id = d2.user_id left join (SELECT
info.user_id FROM ( SELECT two.user_id, sum( IF ( two.question_id IN ( SELECT
DISTINCT one.question_id FROM log_table AS one WHERE one.date between
"2022-09-18" and "2022-09-18" AND one.user_id = two.user_id ), 0, 1 )) AS num
FROM log_table AS two WHERE two.date = "2022-09-19" GROUP BY two.user_id ) info
WHERE info.num >0) as d1 on d5.user_id = d1.user_id

GitHub

Gitee