Calculate Average Event Value by User ID
Company: Upstart
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Technical Screen
Overview: This question evaluates a candidate's skill in group-wise aggregation and data transformation on JSON-like event streams, specifically computing per-user average metrics and producing ranked results.
Tables
events(id INTEGER, user_id INTEGER, event_type VARCHAR(20), value DECIMAL(10,2), timestamp TIMESTAMP)
Hints
- Use AVG(value) with GROUP BY user_id.
- ORDER BY the computed average in descending order.