American Express analysts need to identify customers with the second-highest annual spend within each market segment. Write a PostgreSQL query using DENSE_RANK() or RANK().
| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| customer_name | VARCHAR(100) | Customer name |
| market_segment | VARCHAR(50) | American Express customer market segment |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| customer_id | INT | Customer associated with the transaction |
| transaction_date | DATE | Transaction posting date |
| amount | NUMERIC(12,2) | Transaction amount in dollars |