Interview Query

Comment Upvotes

6
Have you seen this question before?

users table

column type
id integer
created_at datetime
username string

comments table

column 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

 

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.

Output:

column type
id int
username string
upvotes int
Next question: Acceptance Rate
MySQL 8.0.17
Loading editor