Business Context
A bank wants to identify its highest-volume customers for the latest completed calendar quarter. Transaction volume is the sum of absolute values for valid posted transactions on open accounts.
Task
Write a PostgreSQL query that returns the top 10% of eligible customers by transaction volume for the last completed calendar quarter. Use June 15, 2026 as the fixed reporting reference date, so the reporting period is April 1, 2026 through June 30, 2026.
Output
- Return one row per eligible customer with
customer_id, customer_name, and total_transaction_volume.
- Include only customers with open accounts and non-null, posted transactions within the reporting period. Null transaction amounts are ignored.
- Treat debits and credits as positive transaction volume by using their absolute monetary values.
- Return the top 10% of eligible customers, rounding the number of returned customers up when necessary.
- Order by total transaction volume descending, then
customer_id ascending as the deterministic tie-breaker.