Your question is Rank Servers by Abuse Report Ratio. 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.
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 |
report_type = 'abuse'.is_active = true.0 bans.