A set of values given: Assume table in SQL or list of dictionaries if using Python. Basically a row of data contained information: if it is post or it is a comment, row id and some other data. Find distribution of comments. #comments # posts 1 5000 2 6787 .. ..
Sigiloso
Can also be with join, but I did it like this: SELECT Count(a.parent_id), num_com FROM (SELECT id AS parent_id, 0 AS num_com FROM submission WHERE parent_id IS NULL AND id NOT IN (SELECT parent_id FROM submission WHERE parent_id IS NOT NULL) UNION SELECT parent_id, Count(id) AS num_com FROM submission WHERE parent_id IS NOT NULL GROUP BY parent_id) AS a GROUP BY num_com;