Join events and messages to find average revenue
Last updated: February 11, 2026
Quick Overview
Write a query joining events and clicks to produce the combined average revenue.
Morgan Stanley
Data Manipulation (SQL/Python)
Data Scientist
Morgan Stanley
February 11, 2026Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
Hard
0
0
916 solved
Write a query joining events and clicks to produce the combined average revenue.
Data manipulation questions at Morgan Stanley test your ability to work with real-world datasets. This Technical Screen question evaluates your SQL proficiency, understanding of data modeling, and ability to derive insights from raw data.
What the Interviewer Expects
- Solve complex analytical problems with elegant, readable SQL
- Optimize queries for large-scale datasets with partitioning and indexing
- Use recursive CTEs, lateral joins, and advanced window functions
- Design the data model alongside the query solution
- Discuss trade-offs between SQL and programmatic approaches (Python/pandas)
- Consider the operational aspects: query scheduling, incremental processing
Key Topics to Cover
Window functions (ROW_NUMBER, RANK, LAG, LEAD)
NULL handling and COALESCE
Index optimization and query performance
JOIN types and when to use each
Aggregate functions and GROUP BY
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- Can you rewrite this without using subqueries?
- What indexes would you create to support this query?
- How would you handle slowly changing dimensions in this scenario?
- How would you handle this if the data was spread across multiple databases?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Problem Understanding
In this problem, we are dealing with two tables: events and clicks. The events table contains records of user events along with associated revenue, while the clicks table records user ...
Approach
- Identify Key Columns: Determine which columns are needed for the join and the revenue calculation. We will likely need a common identifier between the two tables, such as
event_id, as well as...
Submit Your Answer
Markdown supported