Salesforce data scientist interviews test statistical reasoning, ML model design, SQL proficiency, A/B testing methodology, and Python-based algorithm implementation.
No verified questions yet for Salesforce.
payments with the columns client_id, payment_date, and amount, write a query to compute a retention rate for each client on a month-over-month basis. Consider retention as clients who paid in the current month compared to previous months and return the client_id, month, and retention_rate (as a percentage).sql
client_id | payment_date | amount
-----------|--------------|-------
1 | 2021-01-10 | 100
1 | 2021-02-15 | 150
2 | 2021-01-20 | 200
2 | 2021-03-10 | 100
1 | 2021-03-12 | 200
sql
client_id | month | retention_rate
-----------|-----------|----------------
1 | 2021-01 | NULL
1 | 2021-02 | 100.00
1 | 2021-03 | 50.00
2 | 2021-01 | NULL
2 | 2021-02 | NULL
2 | 2021-03 | 100.00
payment_date will be strictly in the format YYYY-MM-DD.referrals, where each entry is a tuple containing customer_id, timestamp, and reward_points. The function should return a mapping of customer_id to total reward_points earned within a specified time_window (in seconds).def track_referrals(referrals: List[Tuple[str, int, int]], time_window: int) -> Dict[str, int]: — The method returns a dictionary mapping customers to their total reward points within the time window.referrals = [('A', 1, 10), ('B', 2, 20), ('A', 3, 10), ('A', 4, 20)], time_window = 3{'A': 20, 'B': 20}referrals = [('A', 1, 10), ('B', 2, 20), ('A', 5, 30), ('C', 6, 40)], time_window = 5{'A': 10, 'B': 20, 'C': 40}1 <= len(referrals) <= 10^40 <= timestamp <= 10^91 <= reward_points <= 100Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free