how to query multiple counts on related tables For each Forum, there are many Posts, and for each Post, there are many Comments

I'm trying to query the total number of Posts and Comments for each Forum

So I'm looking to have an output as such:

Forum name | post_count | comment_count
honda cars     256          489
toyota cars    53           230


Here are the tables

Forum
::Posts
  ::Comments
If your schema has a useful naming convention it could work like this:

SELECT f.forum, p.post_count, p.comment_count
FROM   forum f
LEFT   JOIN (
   SELECT forum_id, count(*) AS post_count, sum(c_ct) AS comment_count
   FROM   posts p
   LEFT   JOIN (
      SELECT post_id, count(*) AS c_ct
      FROM   comments
      GROUP  BY 1
      ) c USING (post_id)
   GROUP  BY 1
   ) p USING (forum_id);


LEFT JOIN is to include posts without comments and forums without posts.
If you had provided actual table definitions, I wouldn't need to speculate on column names.