SQL · Thumbtack · Medium
Write a single PostgreSQL query, without dynamic SQL, that reports monthly request activity from the requests table, split by whether each request came from a new user or a returning user. For each user, their first request month is defined as: $$ \texttt{DATE\_TRUNC('month', MIN(request\_ts))} $$ over all of that user's rows in requests. A request is classified as new when the month of its request_ts equals that user's first request month. Otherwise, the request is…
Checking your access…