Business Context
American Express Global Business Travel uses Neo reporting to compare corporate travel spend across regional portfolios. The reporting team needs the highest-spending clients for the most recently completed fiscal year.
Task
Write a PostgreSQL query that returns the top three corporate clients by total travel spend within each region for fiscal year 2025, defined as July 1, 2024 through June 30, 2025.
Requirements
- Join regions, corporate clients, and travel transactions.
- Include clients with no qualifying transactions as zero spend, but exclude clients without an assigned region.
- Aggregate transaction amounts by region and client, rank clients within each region, and return ranks 1 through 3.
- Order the output by region ID, rank, and client name. Treat NULL transaction amounts as zero and use client name as the deterministic tie-breaker.