PhonePe UPI operations analysts need the final four characters of each successful numeric UPI reference for reconciliation. Write a PostgreSQL query that joins transactions to merchants and extracts this suffix using LENGTH and SUBSTR.
status is SUCCESS.upi_reference using SUBSTR(upi_reference, LENGTH(upi_reference) - 3, 4).transaction_id.| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| merchant_id | INT | Associated merchant identifier |
| upi_reference | VARCHAR(30) | Numeric UPI reference string |
| status | VARCHAR(20) | Transaction processing status |
| transaction_type | VARCHAR(20) | Payment or refund classification |
| Column | Type | Description |
|---|---|---|
| merchant_idPK | INT | Unique merchant identifier |
| merchant_name | VARCHAR(100) | Merchant display name |
| city | VARCHAR(50) | Merchant operating city |