A social media platform is building a dashboard to track activity on posts. The table contains both posts and comments. A post is a record where parent_id IS NULL. Use the post's sub_id as its post_id in the output. A comment is a record whose parent_id equals the post's sub_id.
For each post, count the number of distinct comments. Return:
- post_id
- number_of_comments
Include posts with no comments, using 0 as their count. Sort the result by post_id.
post_idnumber_of_commentsSign in to see submission history
Sign inSign in to use AI Mentor
Sign in