Shopify Financial Operations needs a monthly view of Shopify Payments activity by merchant for Q1 2025. The report should distinguish settled sales from settled refunds and exclude failed or pending transactions.
Write a PostgreSQL query that joins payment_transactions to shopify_merchants and returns one row per merchant and transaction month.
status = 'settled'.NULL refund rate when gross sales are zero.| Column | Type | Description |
|---|---|---|
| merchant_idPK | INT | Unique Shopify merchant identifier |
| merchant_name | VARCHAR(100) | Merchant display name |
| plan | VARCHAR(30) | Shopify subscription plan |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique payment transaction identifier |
| merchant_id | INT | Merchant associated with the transaction |
| order_id | VARCHAR(30) | Shopify order reference |
| transaction_type | VARCHAR(20) | Payment transaction type |
| status | VARCHAR(20) | Transaction processing status |
| amount | DECIMAL(12,2) | Transaction amount in the reporting currency |
| processed_at | DATE | Date the transaction was processed |