How to get counts and sub_counts of a table with single query?

Original text of this message