Continental Finance wants to identify customers showing concentrated monthly transaction activity. Write a PostgreSQL query that reports customers with more than three completed transactions in a calendar month, using only transactions linked to active accounts.
Requirements
- Join customers, accounts, and transactions.
- Include only transactions from active accounts with
completed status.
- Group transactions by customer and calendar month using PostgreSQL date functions.
- Return the customer, month, transaction count, and total amount. Treat a NULL amount as zero.
- Keep only groups with more than three transactions and order by total amount descending.
Output details
- Return
customer_id, customer_name, month_start, transaction_count, and total_transaction_amount, in that order.
- Represent each calendar month as its first day in
month_start.
- After sorting by
total_transaction_amount descending, break ties by customer_id ascending.