Write a SQL query using window functions to find each T-Mobile customer's most recent transaction and the previous transaction amount.
Use the provided customer and transaction data. Include customers with at least one transaction, and use transaction timestamp plus transaction ID to break ties.
customer_id, customer_name, transaction_id, transaction_timestamp, most_recent_transaction_amount, and previous_transaction_amount.customer_id ascending. Return NULL when no previous transaction exists.| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique T-Mobile customer identifier |
| customer_name | VARCHAR(100) | Customer name |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| customer_id | INT | Customer who made the transaction |
| transaction_timestamp | TIMESTAMP | Timestamp when the transaction occurred |
| amount | DECIMAL(10,2) | Transaction amount in US dollars |