How would you use SQL to identify the top 10 branches by complaint volume and compare them to the previous month?
Use the latest complaint month as the reporting month and compare it with the immediately preceding calendar month. Return only branches with at least one complaint in the reporting month.
rank, branch_code, branch_name, current_month_complaints, previous_month_complaints, volume_change, and percentage_change.| Column | Type | Description |
|---|---|---|
| branch_idPK | INT | Unique branch identifier |
| branch_code | VARCHAR(20) | Operational branch code |
| branch_name | VARCHAR(100) | Branch name |
| city | VARCHAR(80) | Branch city |
| Column | Type | Description |
|---|---|---|
| complaint_idPK | INT | Unique complaint identifier |
| branch_id | INT | Branch associated with the complaint |
| complaint_date | DATE | Date the complaint was received |
| category | VARCHAR(60) | Complaint category |
| status | VARCHAR(30) | Current complaint status |