Given a table of user transactions, write a query using Common Table Expressions (CTEs) to identify churned users, defined as users who transacted last month but not this month.
Use the month containing the latest transaction date as this month, and the immediately preceding calendar month as last month. Exclude transactions with a NULL user_id.
user_id.user_id in ascending order.| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| user_id | INT | Identifier of the user who made the transaction |
| transaction_date | DATE | Date on which the transaction occurred |
| amount | NUMERIC(12,2) | Transaction amount |