Interview Query

Always Excited Users

6
Have you seen this question before?

Let’s say you work at an advertising firm. You have a table of users’ impressions of ad campaigns over time. Each impression_id consists of values of user engagement specified by Excited and Bored.

Write a query to find all users that are currently “Excited” and have never been “Bored” with a campaign.

Example:

Input:

ad_impressions table:

Column Type
user_id INTEGER
dt DATETIME
campaign_id INTEGER
impression_id TEXT

Output:

Column Type
user_id INTEGER
Next question: Three Zebras
.....
MySQL 8.0.17
Loading editor
Use Shift + Enter to run query