Your question is Window Function for Second Rank. Start with the requirements and the two tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
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 |