Your question is Rank Branches by Monthly Revenue. Start with the requirements and the three 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.
You are given the task of analyzing branch performance for a retail banking network. Write a PostgreSQL query that joins and_huntington_transactions, and_huntington_employees, and and_huntington_branches to calculate total monthly revenue per branch and identify the top-performing branch or branches for each month. Treat revenue as the sum of positive transaction amounts only, and ignore rows where the transaction is not tied to a valid employee-branch relationship.
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| employee_id | INT | Employee who handled the transaction |
| transaction_date | DATE | Date the transaction occurred |
| amount | DECIMAL(12,2) | Transaction amount; positive values count as revenue |
| Column | Type | Description |
|---|---|---|
| employee_idPK | INT | Unique employee identifier |
| employee_name | VARCHAR(100) | Employee full name |
| branch_id | INT | Branch assignment for the employee |
| Column | Type | Description |
|---|---|---|
| branch_idPK | INT | Unique branch identifier |
| branch_name | VARCHAR(100) | Branch name |
| city | VARCHAR(100) | City where the branch is located |