题目链接:点击打开链接
题目大意:略。
解题思路:略。
AC 代码
-- 解决方案(1) SELECT COUNT(*) accounts_count FROM Subscriptions WHERE '2021-01-01' BETWEEN start_date AND end_date AND account_id NOT IN (SELECT account_id FROM Streams WHERE YEAR(stream_date) = '2021') -- 解决方案(2) SELECT COUNT(SU.ACCOUNT_ID) accounts_count FROM Subscriptions SU WHERE SU.END_DATE>=TO_DATE('2021-01-01','YYYY-MM-DD') AND NOT EXISTS (SELECT 1 FROM STREAMS ST WHERE ST.ACCOUNT_ID=SU.ACCOUNT_ID AND EXTRACT(YEAR FROM ST.STREAM_DATE)=2021)