Can you walk through your experience writing and optimizing complex SQL queries, stored procedures, and cursors for performance?
For the practical portion, use the provided PostgreSQL tables to produce a merchant-level transaction summary for active cardholders during the first quarter of 2025. Include merchants without qualifying transactions so the result demonstrates both correctness and performance considerations.
Output
- One row per merchant with
merchant_name, category, region, approved_txn_count, total_approved_amount, and average_approved_amount
- Include only approved, non-null, non-negative transactions from active cardholders between January 1 and April 1, 2025
- Include merchants with no qualifying transactions, using zero counts and totals and a null average
- Order by total amount descending, then merchant ID ascending for ties