Interview Query

Attribution Rules

Start Timer

0:00:00

Upvote
8
Downvote
Save question
Mark as completed
View comments (58)
Next question

Write a query that creates an attribution rule for each user. If the user visited Facebook or Google at least once then the attribution is labeled as “paid.” Otherwise, the attribution is labeled as “organic.”

Example:

Input:

user_sessions table

Column Type
created_at DATETIME
session_id INTEGER
user_id INTEGER

attribution table 

Column Type
session_id INTEGER
channel VARCHAR

Output:

Column Type
user_id INTEGER
attribute VARCHAR
.
.
.
.
.


Comments

Loading comments.