← Thumbtack Interview Insights
First, compute each user's first request month using a subquery or window function, then join this back to the requests table to classify each request as NEW or RETURNING. Finally, aggregate by month to get counts and percentage shares, and verify the results against the sample data.
Pro tip: Use a CTE to compute first request month and then join, which is more readable and avoids correlated subqueries. Also, consider edge cases like users with no requests or months with zero requests of one type.
Use a subquery or window function to find the minimum request month for each user from the requests table.
Join the first request month back to the requests table and compare the request month to the first month; label as NEW if equal, else RETURNING.
Group by month and count the number of NEW and RETURNING requests, then compute percentage shares.
Order the results by month ascending and ensure the output columns are month, new_count, returning_count, new_share_pct, returning_share_pct.
Manually compute expected results for the provided sample data and compare with the query output to ensure correctness.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.