Solution: 45. Channels Where Likes Exceed Comments
Hard
Problem Detail:
Write a SQL query to find channels where the sum of likes is greater than the sum of comments.
Answer SQL Query:
SELECT c.channel_name,
SUM(s.like_count) AS total_likes,
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
HAVING SUM(s.like_count) > SUM(s.comment_count);
You can easily copy this solution, switch back to your editor tab, paste it, and run the SQL!