Interview Query

Weighted Average Campaigns

Start Timer

0:00:00

Upvote
1
Downvote
Save question
Mark as completed
View comments (7)
Next question

A marketing team wants to compute a weighted average score to measure the effectiveness of their past email campaigns. They want the weight of the open rate to be 0.3, and the weight of the click rate to be 0.7.

Write a SQL query to calculate the weighted average for each campaign.

Notes: The click rate is the number of clicks over the number of users. The weighted average should be rounded to two decimal places.

Example:

Input:

email_campaigns table

Column Type
campaign_id INTEGER
campaign_name VARCHAR
num_users INTEGER
num_opens INTEGER
num_clicks INTEGER

Output:

Column Type
campaign_name VARCHAR
weighted_avg DECIMAL(4,2)
.
.
.
.
.


Comments

Loading comments