I have three tables
OWNERS: pk name
POSTS: pk, post_date, owner_pk
REPLIES: pk,reply_date, post_pk,owner_pk,comment_count
Between two dates: date1 and date2 I want a result as:
OWNER:name COUNT(posts) SUM(comment_count)
My problem is that I can’t understand how to write a single query that sums the POSTS REPLIES tables separatly.
Ex: Day1 a post is done with 2 comments. Day2 a post is done with no comments. The reply table stores the total number of comments for a given post/day.
PostA Day1
CommentA1 Day1
CommentA2 Day1
PostB Day2
CommentA3 Day2
PostC Day3
Running the query for Day1:
Owner:Name count(post) sum(comment_count)
OwnerName 1 2
Running the query for Day2:
OwnerName 1 1
Running the query for Day3:
OwnerName 1 0
You might need to provide a bit more detail in your question, but I suspect you’re after something like this: