Interview Query

Ad Comments

11
Have you seen this question before?
feed_comments
column type
ad_id integer
user_id integer
comment_id integer

 

moments_comments
column type
ad_id integer
user_id integer
comment_id integer

 

ads
column type
id integer
name varchar

 

You're given three tables.

An ads table holds an ID and the advertisement name like "Labor day shirts sale". The feed_comments table holds the comments on ads by different users that occurs in the regular feed. The moments_comments table holds the comments on ads by different users in the moments section.

Write a query to get the percentage of comments, by ad, that occurs in the feed versus mentions sections of the app.

Output:

name percentage_feed percentage_moments
Labor Day .6 .4
Polo Shirts .85 .15
Next question: Notification Deliveries
MySQL 8.0.17
Loading editor