Extract and clean transaction data using grouping, sorting, and window functions to identify user behavior trends.
Use the provided user and transaction records. Include only completed transactions with a positive, non-null amount and a matching user.
month, user_id, user_name, transaction_count, total_amount, average_amount, and monthly_rank.month ascending, monthly_rank ascending, and user_id ascending.| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique user identifier |
| user_name | VARCHAR(100) | User display name |
| segment | VARCHAR(30) | User segment |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| user_id | INT | User who made the transaction |
| transaction_ts | TIMESTAMP | Transaction timestamp |
| amount | NUMERIC(10,2) | Transaction amount |
| status | VARCHAR(20) | Transaction processing status |
| channel | VARCHAR(20) | Transaction channel |