
Write a PostgreSQL query to find Discord servers with the highest ratio of abuse reports to active users. Return server_id, abuse report count, active user count, total bans, and the ratio. Only include servers with at least 2 active users, and sort by ratio descending, then server_id ascending.
| Column | Type | Description |
|---|---|---|
| member_id | ||
| server_id | ||
| user_id | ||
| is_active | ||
| joined_at |
| Column | Type | Description |
|---|---|---|
| report_id | ||
| server_id | ||
| reporter_user_id | ||
| reported_user_id | ||
| report_type | ||
| created_at |
| Column | Type | Description |
|---|---|---|
| ban_id | ||
| server_id | ||
| banned_user_id | ||
| banned_at |
Count only rows where `report_type = 'abuse'`.Treat a user as active only when `is_active = true`.Servers with no bans should still appear with `0` bans.Avoid overcounting by aggregating before joining.