Comment Upvotes
Start Timer
0:00:00
We’re given three tables representing a forum of users and their comments on posts.
Write a query to get the top three users that got the most upvotes on their comments written in 2020.
Note: Do not count deleted comments and upvotes by users on their own comments
Example:
Input:
users
table
Column | Type |
---|---|
id |
INTEGER |
created_at |
DATETIME |
username |
VARCHAR |
comments
table
Columns | Type |
---|---|
id |
INTEGER |
created_at |
datetime |
post_id |
INTEGER |
user_id |
INTEGER |
is_deleted |
BOOLEAN |
comment_votes
table
Column | Type |
---|---|
id |
INTEGER |
created_at |
DATETIME |
user_id |
INTEGER |
comment_id |
INTEGER |
is_upvote |
BOOLEAN |
Output:
Column | Type |
---|---|
id |
INTEGER |
username |
VARCHAR |
upvotes |
INTEGER |
Recommended questions for you
Personalized based on your user activity, skill level, and preferences.
.
.
.
.
.
.
.
.
.
Comments