File tree 6 files changed +67
-10
lines changed
6 files changed +67
-10
lines changed Original file line number Diff line number Diff line change @@ -51,17 +51,26 @@ Views 表:
51
51
+------+
52
52
</pre >
53
53
54
-
55
54
## 解法
56
55
57
56
<!-- 这里可写通用的实现逻辑 -->
58
57
58
+ “` DISTINCT ` + ` ORDER BY ` ” 实现。
59
+
59
60
<!-- tabs:start -->
60
61
61
62
### ** SQL**
62
63
63
64
``` 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;
65
74
```
66
75
67
- <!-- tabs:end -->
76
+ <!-- tabs:end -->
Original file line number Diff line number Diff line change @@ -48,15 +48,22 @@ Result table:
48
48
+------+
49
49
</pre >
50
50
51
-
52
51
## Solutions
53
52
54
53
<!-- tabs:start -->
55
54
56
55
### ** SQL**
57
56
58
57
``` 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;
60
67
```
61
68
62
- <!-- tabs:end -->
69
+ <!-- tabs:end -->
Original file line number Diff line number Diff line change
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;
Original file line number Diff line number Diff line change @@ -49,17 +49,28 @@ Result table:
49
49
| 6 |
50
50
+------+</pre >
51
51
52
-
53
52
## 解法
54
53
55
54
<!-- 这里可写通用的实现逻辑 -->
56
55
56
+ “` DISTINCT ` + ` GROUP BY ` ” 实现。
57
+
57
58
<!-- tabs:start -->
58
59
59
60
### ** SQL**
60
61
61
62
``` 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;
63
74
```
64
75
65
- <!-- tabs:end -->
76
+ <!-- tabs:end -->
Original file line number Diff line number Diff line change @@ -56,7 +56,17 @@ Result table:
56
56
### ** SQL**
57
57
58
58
``` 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;
60
70
```
61
71
62
72
<!-- tabs:end -->
Original file line number Diff line number Diff line change
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;
You can’t perform that action at this time.
0 commit comments