diff options
Diffstat (limited to 'server/migrations/2019-04-03-155205_create_community_view/up.sql')
-rw-r--r-- | server/migrations/2019-04-03-155205_create_community_view/up.sql | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/server/migrations/2019-04-03-155205_create_community_view/up.sql b/server/migrations/2019-04-03-155205_create_community_view/up.sql index 74972507..d26a313e 100644 --- a/server/migrations/2019-04-03-155205_create_community_view/up.sql +++ b/server/migrations/2019-04-03-155205_create_community_view/up.sql @@ -3,7 +3,8 @@ select *, (select name from user_ u where c.creator_id = u.id) as creator_name, (select name from category ct where c.category_id = ct.id) as category_name, (select count(*) from community_follower cf where cf.community_id = c.id) as number_of_subscribers, -(select count(*) from post p where p.community_id = c.id) as number_of_posts +(select count(*) from post p where p.community_id = c.id) as number_of_posts, +(select count(*) from comment co, post p where c.id = p.community_id and p.id = co.post_id) as number_of_comments from community c; create view community_moderator_view as |