1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/文章浏览 I [article-views-i].html

52 lines
1.4 KiB
HTML
Raw Normal View History

2022-03-27 20:37:52 +08:00
<p><code>Views</code>&nbsp;表:</p>
<pre>
+---------------+---------+
| Column Name | Type |
+---------------+---------+
| article_id | int |
| author_id | int |
| viewer_id | int |
| view_date | date |
+---------------+---------+
2023-12-09 18:42:21 +08:00
此表可能会存在重复行。(换句话说,在 SQL 中这个表没有主键)
2022-03-27 20:37:52 +08:00
此表的每一行都表示某人在某天浏览了某位作者的某篇文章。
请注意,同一人的 author_id 和 viewer_id 是相同的。
</pre>
<p>&nbsp;</p>
2023-12-09 18:42:21 +08:00
<p>请查询出所有浏览过自己文章的作者</p>
<p>结果按照 <code>id</code> 升序排列。</p>
2022-03-27 20:37:52 +08:00
<p>查询结果的格式如下所示:</p>
2023-12-09 18:42:21 +08:00
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
2022-03-27 20:37:52 +08:00
<pre>
2023-12-09 18:42:21 +08:00
<strong>输入:</strong>
2022-03-27 20:37:52 +08:00
Views 表:
+------------+-----------+-----------+------------+
| article_id | author_id | viewer_id | view_date |
+------------+-----------+-----------+------------+
| 1 | 3 | 5 | 2019-08-01 |
| 1 | 3 | 6 | 2019-08-02 |
| 2 | 7 | 7 | 2019-08-01 |
| 2 | 7 | 6 | 2019-08-02 |
| 4 | 7 | 1 | 2019-07-22 |
| 3 | 4 | 4 | 2019-07-21 |
| 3 | 4 | 4 | 2019-07-21 |
+------------+-----------+-----------+------------+
2023-12-09 18:42:21 +08:00
<strong>输出:</strong>
2022-03-27 20:37:52 +08:00
+------+
| id |
+------+
| 4 |
| 7 |
+------+
</pre>