Robinhood OA | Phone interview

'''

Table 1: gold_subscriptions

-----------------------

This table tracks, for each Robinhood user, the starting and ending dates of their historical gold membership subscriptions. Users who have never had subscriptions would not be included in this table. Each row represents a subscription: a user with X historical subscriptions would have X rows in the table. For a user’s most recent subscription, the column ended_at would be null if the membership is currently active.

user_id

started_at

ended_at

Table 2: deposits

-----------------------

This table tracks, for each historical deposit into Robinhood, the initiation time as well as amount (along with the associated user_id).

transfer_id (primary key)

user_id

started_at

amount

For both tables, assume that you are working with the most recently available snapshot that contains all historical data up to today.

-----------------------------------

Question 1:

For each historical deposit, we want to know if the corresponding user has an active gold membership at the time of making the deposit.

Output a table with columns:

transfer_id

user_is_gold (boolean)

-----------------------------------

Question 2:

We want to identify the set of all users who have made at least 7 deposits that are each >= 1000.

user_id

ts

with checking_for_gold(
select user_id
from gold_subscriptions
where ended_at is null;
),
with intermediate_table(
select transfer_id,
1 as user_is_gold,
from deposits d join checking_for_gold c on d.user_id = c.user_id
)

Comments (3)