Skip to content

Commit cfeb7f2

Browse files
committed
feat: add solutions to lc problems: No.1148, No.1149
1 parent 296602c commit cfeb7f2

File tree

6 files changed

+67
-10
lines changed

6 files changed

+67
-10
lines changed

solution/1100-1199/1148.Article Views I/README.md

+12-3
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,26 @@ Views 表:
5151
+------+
5252
</pre>
5353

54-
5554
## 解法
5655

5756
<!-- 这里可写通用的实现逻辑 -->
5857

58+
`DISTINCT` + `ORDER BY`” 实现。
59+
5960
<!-- tabs:start -->
6061

6162
### **SQL**
6263

6364
```sql
64-
65+
# Write your MySQL query statement below
66+
SELECT
67+
DISTINCT(author_id) as id
68+
FROM
69+
Views
70+
WHERE
71+
author_id = viewer_id
72+
ORDER BY
73+
id;
6574
```
6675

67-
<!-- tabs:end -->
76+
<!-- tabs:end -->

solution/1100-1199/1148.Article Views I/README_EN.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,22 @@ Result table:
4848
+------+
4949
</pre>
5050

51-
5251
## Solutions
5352

5453
<!-- tabs:start -->
5554

5655
### **SQL**
5756

5857
```sql
59-
58+
# Write your MySQL query statement below
59+
SELECT
60+
DISTINCT(author_id) as id
61+
FROM
62+
Views
63+
WHERE
64+
author_id = viewer_id
65+
ORDER BY
66+
id;
6067
```
6168

62-
<!-- tabs:end -->
69+
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Write your MySQL query statement below
2+
SELECT
3+
DISTINCT(author_id) as id
4+
FROM
5+
Views
6+
WHERE
7+
author_id = viewer_id
8+
ORDER BY
9+
id;

solution/1100-1199/1149.Article Views II/README.md

+14-3
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,28 @@ Result table:
4949
| 6 |
5050
+------+</pre>
5151

52-
5352
## 解法
5453

5554
<!-- 这里可写通用的实现逻辑 -->
5655

56+
`DISTINCT` + `GROUP BY`” 实现。
57+
5758
<!-- tabs:start -->
5859

5960
### **SQL**
6061

6162
```sql
62-
63+
# Write your MySQL query statement below
64+
SELECT
65+
DISTINCT(viewer_id) as id
66+
FROM
67+
Views
68+
GROUP BY
69+
view_date, viewer_id
70+
HAVING
71+
COUNT(DISTINCT(article_id)) > 1
72+
ORDER BY
73+
id;
6374
```
6475

65-
<!-- tabs:end -->
76+
<!-- tabs:end -->

solution/1100-1199/1149.Article Views II/README_EN.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,17 @@ Result table:
5656
### **SQL**
5757

5858
```sql
59-
59+
# Write your MySQL query statement below
60+
SELECT
61+
DISTINCT(viewer_id) as id
62+
FROM
63+
Views
64+
GROUP BY
65+
view_date, viewer_id
66+
HAVING
67+
COUNT(DISTINCT(article_id)) > 1
68+
ORDER BY
69+
id;
6070
```
6171

6272
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Write your MySQL query statement below
2+
SELECT
3+
DISTINCT(viewer_id) as id
4+
FROM
5+
Views
6+
GROUP BY
7+
view_date, viewer_id
8+
HAVING
9+
COUNT(DISTINCT(article_id)) > 1
10+
ORDER BY
11+
id;

0 commit comments

Comments
 (0)