LeetCode(数据库)- Number of Accounts That Did Not Stream

Posted 程序员牧码

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode(数据库)- Number of Accounts That Did Not Stream相关的知识,希望对你有一定的参考价值。

题目链接:点击打开链接

题目大意:略。

解题思路:略。

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)

以上是关于LeetCode(数据库)- Number of Accounts That Did Not Stream的主要内容,如果未能解决你的问题,请参考以下文章

LeetCode Number of Boomerangs

LeetCode(191):Number of 1 Bits

[LeetCode]Number of 1 Bits

Leetcode 200. Number of Islands

LeetCode 191. Number of 1 Bits

LeetCode(数据库)- Number of Accounts That Did Not Stream