Skip to content

Commit bcd1c7c

Browse files
committed
task: #1141
1 parent 642cd52 commit bcd1c7c

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Have a good contributing!
5151
- [627. Swap Salary](./leetcode/easy/627.%20Swap%20Salary.sql)
5252
- [1068. Product Sales Analysis I](./leetcode/easy/1068.%20Product%20Sales%20Analysis%20I.sql)
5353
- [1075. Project Employees I](./leetcode/easy/1075.%20Project%20Employees%20I.sql)
54+
- [1141. User Activity for the Past 30 Days I](./leetcode/easy/1141.%20User%20Activity%20for%20the%20Past%2030%20Days%20I.sql)
5455
- [1148. Article Views I](./leetcode/easy/1148.%20Article%20Views%20I.sql)
5556
- [1327. List the Products Ordered in a Period](./leetcode/easy/1327.%20List%20the%20Products%20Ordered%20in%20a%20Period.sql)
5657
- [1378. Replace Employee ID With The Unique Identifier](./leetcode/easy/1378.%20Replace%20Employee%20ID%20With%20The%20Unique%20Identifier.sql)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
Question 1141. User Activity for the Past 30 Days I
3+
Link: https://leetcode.com/problems/user-activity-for-the-past-30-days-i/description/?envType=study-plan-v2&envId=top-sql-50
4+
5+
Table: Activity
6+
7+
+---------------+---------+
8+
| Column Name | Type |
9+
+---------------+---------+
10+
| user_id | int |
11+
| session_id | int |
12+
| activity_date | date |
13+
| activity_type | enum |
14+
+---------------+---------+
15+
This table may have duplicate rows.
16+
The activity_type column is an ENUM (category) of type ('open_session', 'end_session', 'scroll_down', 'send_message').
17+
The table shows the user activities for a social media website.
18+
Note that each session belongs to exactly one user.
19+
20+
21+
Write a solution to find the daily active user count for a period of 30 days ending 2019-07-27 inclusively. A user was active on someday if they made at least one activity on that day.
22+
23+
Return the result table in any order.
24+
*/
25+
26+
SELECT
27+
activity_date AS day, --noqa: RF04
28+
COUNT(DISTINCT user_id) AS active_users
29+
FROM Activity
30+
WHERE activity_date BETWEEN DATE '2019-07-27' - INTERVAL '29 days' AND DATE '2019-07-27'
31+
GROUP BY day

0 commit comments

Comments
 (0)