Join clicks and clicks to find average revenue
Last updated: December 2, 2025
Quick Overview
Write a query joining clicks and transactions to produce the combined average revenue.
DoorDash
Data Manipulation (SQL/Python)
Data Scientist
DoorDash
December 2, 2025Data Scientist
Onsite
Data Manipulation (SQL/Python)
Medium
31
2
3,878 solved
Write a query joining clicks and transactions to produce the combined average revenue.
DoorDash asks this during the Onsite because data engineering skills are critical for the role. You should be comfortable with complex joins, window functions, CTEs, and performance optimization.
What the Interviewer Expects
- Use advanced SQL features: window functions, CTEs, subqueries
- Write efficient queries that avoid common performance pitfalls
- Handle complex data transformations with multiple joins and aggregations
- Discuss indexing strategy and query optimization
- Address data quality issues: duplicates, missing values, outliers
Key Topics to Cover
Pandas vectorized operations and groupby
Subqueries and correlated subqueries
Window functions (ROW_NUMBER, RANK, LAG, LEAD)
Date/time manipulation
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 indexes would you create to support this query?
- How would you handle slowly changing dimensions in this scenario?
- How would you optimize this query for a table with 100 million rows?
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
The task involves two main datasets: clicks and transactions. The clicks table contains data regarding user clicks on the DoorDash platform, while the transactions table records completed purc...
Approach
- Identify Key Columns: Determine the primary keys and relevant columns in both tables. For example,
clicksmight haveuser_id,click_timestamp, andcampaign_id, whiletransactionsmigh...
Submit Your Answer
Markdown supported