Solution: 38. Top 5 Channels by Total Comments
Medium
Problem Detail:
Write a SQL query to find the top 5 channels by total comments across all their videos.
Answer SQL Query:
SELECT c.channel_name,
SUM(s.comment_count) AS total_comments
FROM channels c
JOIN videos v
ON c.channel_id = v.channel_id
JOIN video_stats s
ON v.video_id = s.video_id
GROUP BY c.channel_id, c.channel_name
ORDER BY total_comments DESC
LIMIT 5;
You can easily copy this solution, switch back to your editor tab, paste it, and run the SQL!