Your question is Find Recent Failed Merchant Transactions. 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.
You are given transaction data and merchant metadata. Write a PostgreSQL query that returns all failed transactions for a specific merchant ID in the last 24 hours, including the merchant name and transaction details.
| Column | Type | Description |
|---|---|---|
| merchant_idPK | BIGINT | Primary key for the merchant |
| merchant_name | VARCHAR(255) | Display name for the merchant |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | BIGINT | Primary key for the transaction |
| merchant_id | BIGINT | Foreign key to merchants.merchant_id |
| status | VARCHAR(50) | Transaction status such as succeeded or failed |
| amount | NUMERIC(12,2) | Transaction amount |
| currency | CHAR(3) | ISO currency code |
| created_at | TIMESTAMPTZ | Timestamp when the transaction was created |