Your question is Window Functions for Running Totals. Start with the requirements and the two tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
NewMarket wants to evaluate user engagement by signup cohort. Write a PostgreSQL query that summarizes qualifying transactions by user and calendar month, calculates each user's cumulative spend, and ranks users within their signup cohort.
cohort_month from users.signup_date and activity_month from transactions.transaction_date.| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique NewMarket user identifier |
| user_name | VARCHAR(100) | User display name |
| signup_date | DATE | Date the user joined NewMarket |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| user_id | INT | User associated with the transaction |
| transaction_date | DATE | Date of the transaction |
| amount | NUMERIC(10,2) | Transaction amount |