Write a query to find DAU/MAU ratio from transactions
Last updated: April 12, 2026
Quick Overview
Write a SQL query to calculate DAU/MAU ratio from the transactions table, considering nulls and duplicates.
Dropbox
April 12, 202650
5
3,173 solved
Write a SQL query to calculate DAU/MAU ratio from the transactions table, considering nulls and duplicates.
This question from Dropbox's Technical Screen 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
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
- What would you do if this query needs to run every 5 minutes?
- How would you optimize this query for a table with 100 million rows?
- How would you handle slowly changing dimensions in this scenario?
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
To compute the DAU (Daily Active Users) to MAU (Monthly Active Users) ratio from the transactions table, we first need to identify the relevant data. The transactions table likely contains at least tw...
Approach
- Select Unique Users: Use
DISTINCTto select uniqueuser_idvalues for DAU and MAU calculations. - Calculate DAU: Group by the date (
transaction_date) to count unique users for each...