Join orders and events to find DAU/MAU ratio
Last updated: September 10, 2025
Quick Overview
Write a query joining orders and rides to produce the combined DAU/MAU ratio.
Elastic
Data Manipulation (SQL/Python)
Data Scientist
Elastic
September 10, 2025Data Scientist
Onsite
Data Manipulation (SQL/Python)
Easy
106
6
4,262 solved
Write a query joining orders and rides to produce the combined DAU/MAU ratio.
This question from Elastic's Onsite tests practical data skills. The interviewer wants to see clean, efficient queries that handle edge cases like NULLs, duplicates, and large datasets.
What the Interviewer Expects
- Write syntactically correct SQL with proper JOIN and WHERE clauses
- Use GROUP BY and aggregate functions appropriately
- Handle NULL values correctly in your queries
- Explain the query execution plan at a high level
Key Topics to Cover
Pandas vectorized operations and groupby
JOIN types and when to use each
Common Table Expressions (CTEs)
Window functions (ROW_NUMBER, RANK, LAG, LEAD)
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
- How would you optimize this query for a table with 100 million rows?
- How would you handle slowly changing dimensions in this scenario?
- What would you do if this query needs to run every 5 minutes?
- What indexes would you create to support this query?
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
We have two tables: orders and events. The orders table contains data about customer orders including the order date and customer ID, while the events table tracks user events such as rides wi...
Approach
- Data Extraction: Start by extracting unique users from both
ordersandeventstables within the last 30 days. This will involve filtering the records based on the date. - Aggregation:...
Submit Your Answer
Markdown supported