-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArticleViewsISchema.sql
18 lines (14 loc) · 1.01 KB
/
ArticleViewsISchema.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
-- Write an SQL query to find all the authors that viewed at least one of their own articles.
-- Return the result table sorted by id in ascending order.
-- SCHEMA
BEGIN TRANSACTION;
DROP TABLE IF EXISTS Views;
Create table If Not Exists Views (article_id int, author_id int, viewer_id int, view_date date);
insert into Views (article_id, author_id, viewer_id, view_date) values ('1', '3', '5', '2019-08-01');
insert into Views (article_id, author_id, viewer_id, view_date) values ('1', '3', '6', '2019-08-02');
insert into Views (article_id, author_id, viewer_id, view_date) values ('2', '7', '7', '2019-08-01');
insert into Views (article_id, author_id, viewer_id, view_date) values ('2', '7', '6', '2019-08-02');
insert into Views (article_id, author_id, viewer_id, view_date) values ('4', '7', '1', '2019-07-22');
insert into Views (article_id, author_id, viewer_id, view_date) values ('3', '4', '4', '2019-07-21');
insert into Views (article_id, author_id, viewer_id, view_date) values ('3', '4', '4', '2019-07-21');
COMMIT;