Skip to content

Commit 10c2a81

Browse files
committed
feat: add sql solution to lc problems: No.1141,1693,1729
- No.1141.User Activity for the Past 30 Days I - No.1693.Daily Leads and Partners - No.1729.Find Followers Count
1 parent 55f50cb commit 10c2a81

File tree

9 files changed

+56
-12
lines changed

9 files changed

+56
-12
lines changed

solution/1100-1199/1141.User Activity for the Past 30 Days I/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,15 @@ Activity table:
7171
### **SQL**
7272

7373
```sql
74-
74+
SELECT
75+
activity_date AS day,
76+
COUNT(DISTINCT user_id) AS active_users
77+
FROM
78+
Activity
79+
WHERE
80+
DATEDIFF('2019-07-27', activity_date) < 30
81+
GROUP BY
82+
activity_date;
7583
```
7684

7785
<!-- tabs:end -->

solution/1100-1199/1141.User Activity for the Past 30 Days I/README_EN.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,15 @@ Activity table:
6767
### **SQL**
6868

6969
```sql
70-
70+
SELECT
71+
activity_date AS day,
72+
COUNT(DISTINCT user_id) AS active_users
73+
FROM
74+
Activity
75+
WHERE
76+
DATEDIFF('2019-07-27', activity_date) < 30
77+
GROUP BY
78+
activity_date;
7179
```
7280

7381
<!-- tabs:end -->
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
SELECT
2+
activity_date AS day,
3+
COUNT(DISTINCT user_id) AS active_users
4+
FROM
5+
Activity
6+
WHERE
7+
DATEDIFF('2019-07-27', activity_date) < 30
8+
GROUP BY
9+
activity_date;

solution/1600-1699/1693.Daily Leads and Partners/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,13 @@
6868
### **SQL**
6969

7070
```sql
71-
71+
SELECT date_id,
72+
make_name,
73+
COUNT(DISTINCT lead_id) AS unique_leads,
74+
COUNT(DISTINCT partner_id) AS unique_partners
75+
FROM DailySales
76+
GROUP BY date_id,
77+
make_name;
7278
```
7379

7480
<!-- tabs:end -->

solution/1600-1699/1693.Daily Leads and Partners/README_EN.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,13 @@ For 2020-12-7, toyota gets leads = [0] and partners = [1, 2] while honda gets le
6969
### **SQL**
7070

7171
```sql
72-
72+
SELECT date_id,
73+
make_name,
74+
COUNT(DISTINCT lead_id) AS unique_leads,
75+
COUNT(DISTINCT partner_id) AS unique_partners
76+
FROM DailySales
77+
GROUP BY date_id,
78+
make_name;
7379
```
7480

7581
<!-- tabs:end -->
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
SELECT date_id,
2+
make_name,
3+
COUNT(DISTINCT lead_id) AS unique_leads,
4+
COUNT(DISTINCT partner_id) AS unique_partners
5+
FROM DailySales
6+
GROUP BY date_id,
7+
make_name;

solution/1700-1799/1729.Find Followers Count/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@
6060
### **SQL**
6161

6262
```sql
63-
# Write your MySQL query statement below
6463
SELECT
65-
user_id, count(1) AS followers_count
64+
user_id,
65+
count(1) AS followers_count
6666
FROM
6767
Followers
6868
GROUP BY
6969
user_id
7070
ORDER BY
71-
user_id
71+
user_id;
7272
```
7373

7474
<!-- tabs:end -->

solution/1700-1799/1729.Find Followers Count/README_EN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ The followers of 2 are {0,1}
5959
### **SQL**
6060

6161
```sql
62-
# Write your MySQL query statement below
6362
SELECT
64-
user_id, count(1) AS followers_count
63+
user_id,
64+
count(1) AS followers_count
6565
FROM
6666
Followers
6767
GROUP BY
6868
user_id
6969
ORDER BY
70-
user_id
70+
user_id;
7171
```
7272

7373
<!-- tabs:end -->

solution/1700-1799/1729.Find Followers Count/Solution.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Write your MySQL query statement below
21
SELECT
3-
user_id, count(1) AS followers_count
2+
user_id,
3+
count(1) AS followers_count
44
FROM
55
Followers
66
GROUP BY

0 commit comments

Comments
 (0)