Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Most Flagged Users

Return each user who has at least one flagged comment with the number of flagged comments. Order by count descending, then name.

Table schema

Users(user_id INT PRIMARY KEY, name VARCHAR(20))
Comments(comment_id INT PRIMARY KEY, post_id INT, user_id INT, created_at DATETIME, flagged INT)

Sample data

Users
user_id | name
1 | Mia
2 | Noah
3 | Omar

Comments
comment_id | post_id | user_id | created_at | flagged
1 | 10 | 1 | 2026-05-01 09:00 | 0
2 | 10 | 2 | 2026-05-01 09:30 | 1
3 | 10 | 2 | 2026-05-01 10:00 | 1
4 | 11 | 3 | 2026-05-02 08:00 | 0
5 | 11 | 1 | 2026-05-02 08:10 | 0
6 | 12 | 2 | 2026-05-03 12:00 | 1
7 | 12 | 3 | 2026-05-03 11:00 | 0

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.