Skip to content

Commit 42b859f

Browse files
authored
Create number-of-accounts-that-did-not-stream.sql
1 parent 9aa9f8c commit 42b859f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Time: O(m + n)
2+
# Space: O(m + n)
3+
4+
WITH bought_cte AS
5+
(
6+
SELECT account_id
7+
FROM Subscriptions
8+
WHERE end_date >= '2021-01-01'
9+
),
10+
no_stream_cte AS
11+
(
12+
SELECT account_id
13+
FROM Streams
14+
WHERE stream_date < '2021-01-01'
15+
)
16+
17+
SELECT COUNT(a.account_id) AS accounts_count
18+
FROM bought_cte a
19+
INNER JOIN no_stream_cte b
20+
ON a.account_id = b.account_id;

0 commit comments

Comments
 (0)