Interview Query

Liked and Commented

5
Have you seen this question before?

You’re given two tables, users and events. The events table holds values of all of the user events in the action column (‘like’, ‘comment’, or ‘post’).

Write a query to get the percentage of users that have never liked or commented. Round to two decimal places.

Example:

Input:

users table

Column Type
id INTEGER
name VARCHAR
created_at DATETIME

events table

Column Type
user_id INTEGER
action VARCHAR
created_at DATETIME

Output:

Column Type
percent_never FLOAT
Next question: Netflix Price
.....
MySQL 8.0.17
Loading editor
Use Shift + Enter to run query