Interview Query

Facebook Data Scientist | August 2020

Company: Facebook

Position: Data Scientist

Location: nan

Level: nan

Outcome: NA

How was the interview process? What was it like?

no

What technical questions were asked?

nan

What was one of your solutions?

I don't have the solution but this is how I did it (I could be wrong).
Question 1: 
SELECT 
    suggested_gif_ids, COUNT(suggested_gif_ids) AS gif_count
FROM
    events sent,
    events received
WHERE
    sent.gif_id = received.gif_id
        AND sent.event = 'clicked_gif_suggestion'
GROUP BY suggested_gif_ids
ORDER BY gif_count DESC, suggested_gif_ids ASC
LIMIT 5;
Question 2: 
SELECT 
    CASE
        WHEN age >= 15 AND age <= 25 THEN '15-25'
        WHEN age >= 45 AND age <= 55 THEN '45-55'
    END AS age_group,
    COUNT(CASE
        WHEN events.event = 'clicked_gif_suggestion' THEN 1
        ELSE 0
    END) / COUNT(CASE
        WHEN events.event = 'suggested_4_options' THEN 1
        ELSE 0
    END) AS ctr
FROM
    dim_all_users users
        LEFT JOIN
    events ON users.user_id = events.user_id
GROUP BY age_group ASC;

0 Comments

Sort By: Default

Edit Post

Tag your post (e.g. "Amazon", "Data Scientist" ...)

Preview