Your question is Running Monthly Transaction Balance. 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.
JPMorganChase wants a transaction-level view of customer credit card activity. Write a PostgreSQL query that calculates each user's running balance separately for every calendar month.
users and return the user's ID and name.month_start as the first day of the transaction month.| Column | Type | Description |
|---|---|---|
| user_idPK | INTEGER | Unique customer identifier |
| full_name | VARCHAR(100) | Customer's full name |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INTEGER | Unique transaction identifier |
| user_id | INTEGER | References users.user_id |
| transaction_date | DATE | Date the transaction occurred |
| amount | NUMERIC(12,2) | Transaction amount, where negative values represent credits or refunds |
| status | VARCHAR(20) | Transaction processing status |