This question evaluates SQL skills for data manipulation, including aggregation, joins, deduplication of repeated user actions, and conditional counting based on review status.
You are designing SQL queries for YouTube Trust & Safety. Use the schema and sample data below. Unless stated otherwise, treat a flag as reviewed if there exists a Reviews row for that flag with a non-NULL reviewed_outcome. If a user flags the same video multiple times, count that user at most once per video when asked for distinct-user counts. If multiple items tie for a maximum, return all ties. Schema:
Sample rows (minimal, illustrative): Users +---------+------------+-----------+ | user_id | first_name | last_name | +---------+------------+-----------+ | 1 | Alice | Zhang | | 2 | Bob | Li | | 3 | Carol | Chen | +---------+------------+-----------+ Videos +----------+----------------+ | video_id | title | +----------+----------------+ | 10 | Cat Tricks | | 11 | Dog Tricks | | 12 | Bird Tricks | +----------+----------------+ Flags +---------+---------+----------+---------------------+ | flag_id | user_id | video_id | flagged_at | +---------+---------+----------+---------------------+ | 100 | 1 | 10 | 2025-08-30 10:00:00 | | 101 | 1 | 10 | 2025-08-31 09:00:00 | | 102 | 2 | 10 | 2025-08-31 12:00:00 | | 103 | 2 | 11 | 2025-09-01 08:30:00 | | 104 | 3 | 10 | 2025-09-01 11:45:00 | | 105 | 3 | 12 | 2025-09-01 12:00:00 | +---------+---------+----------+---------------------+ Reviews +---------+---------------+------------------+ | flag_id | reviewed_date | reviewed_outcome | +---------+---------------+------------------+ | 100 | 2025-09-02 | APPROVED | | 101 | 2025-09-02 | REJECTED | | 102 | 2025-09-03 | APPROVED | | 103 | 2025-09-03 | APPROVED | | 104 | NULL | NULL | +---------+---------------+------------------+ Tasks — write standard SQL for each: