File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed
Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -851,6 +851,7 @@ _If you like this project, please leave me a star._ ★
851851| 1251| [ Average Selling Price] ( https://leetcode.com/problems/average-selling-price// ) | [ Solution] ( ../master/database/_1251.sql ) | | Easy |
852852| 1179| [ Reformat Department Table] ( https://leetcode.com/problems/reformat-department-table/ ) | [ Solution] ( ../master/database/_1179.sql ) | | Easy |
853853| 1173| [ Immediate Food Delivery I] ( https://leetcode.com/problems/immediate-food-delivery-i/ ) | [ Solution] ( ../master/database/_1173.sql ) | | Easy |
854+ | 1148| [ Article Views I] ( https://leetcode.com/problems/article-views-i/ ) | [ Solution] ( ../master/database/_1148.sql ) | | Easy |
854855| 1069| [ Product Sales Analysis II] ( https://leetcode.com/problems/product-sales-analysis-ii/ ) | [ Solution] ( ../master/database/_1069.sql ) | | Easy |
855856| 1068| [ Product Sales Analysis I] ( https://leetcode.com/problems/product-sales-analysis-i/ ) | [ Solution] ( ../master/database/_1068.sql ) | | Easy |
856857| 627| [ Swap Salary] ( https://leetcode.com/problems/swap-salary/ ) | [ Solution] ( ../master/database/_627.sql ) | | Easy |
Original file line number Diff line number Diff line change 1+ -- 1148. Article Views I
2+ --
3+ -- Table: Views
4+ --
5+ -- +---------------+---------+
6+ -- | Column Name | Type |
7+ -- +---------------+---------+
8+ -- | article_id | int |
9+ -- | author_id | int |
10+ -- | viewer_id | int |
11+ -- | view_date | date |
12+ -- +---------------+---------+
13+ -- There is no primary key for this table, it may have duplicate rows.
14+ -- Each row of this table indicates that some viewer viewed an article (written by some author) on some date.
15+ -- Note that equal author_id and viewer_id indicate the same person.
16+ --
17+ --
18+ -- Write an SQL query to find all the authors that viewed at least one of their own articles, sorted in ascending order by their id.
19+ --
20+ -- The query result format is in the following example:
21+ --
22+ -- Views table:
23+ -- +------------+-----------+-----------+------------+
24+ -- | article_id | author_id | viewer_id | view_date |
25+ -- +------------+-----------+-----------+------------+
26+ -- | 1 | 3 | 5 | 2019-08-01 |
27+ -- | 1 | 3 | 6 | 2019-08-02 |
28+ -- | 2 | 7 | 7 | 2019-08-01 |
29+ -- | 2 | 7 | 6 | 2019-08-02 |
30+ -- | 4 | 7 | 1 | 2019-07-22 |
31+ -- | 3 | 4 | 4 | 2019-07-21 |
32+ -- | 3 | 4 | 4 | 2019-07-21 |
33+ -- +------------+-----------+-----------+------------+
34+ --
35+ -- Result table:
36+ -- +------+
37+ -- | id |
38+ -- +------+
39+ -- | 4 |
40+ -- | 7 |
41+ -- +------+
42+
43+ -- # Write your MySQL query statement below
44+ select distinct (author_id) as id from Views where author_id = viewer_id order by id asc ;
You can’t perform that action at this time.
0 commit comments