This question evaluates competency in SQL-based data manipulation and temporal user-metric calculation, focusing on aggregations and distinct-user counts derived from reply relationships within defined time windows.

You are analyzing discussions on a social platform.
all_postpost_id
(BIGINT, PK)
post_author_id
(BIGINT, FK →
user.user_id
)
post_creation_time
(TIMESTAMP, UTC)
post_type
(VARCHAR) — e.g.,
'root'
for an original post and
'reply'
for a reply
post_content
(TEXT)
post_parent_id
(BIGINT, nullable) — if this is a reply, points to the parent post’s
post_id
;
NULL
for root posts
useruser_id
(BIGINT, PK)
age
(INT)
country
(VARCHAR) — e.g.,
'US'
all_post
with
post_parent_id IS NOT NULL
.
post_parent_id
points to a post authored by that user.
reply.post_creation_time
is in
[parent.post_creation_time, parent.post_creation_time + INTERVAL '7 days']
(inclusive). Use UTC.
post_author_id
(the parent post’s author) who have
at least one parent post
that received
≥ 2 replies
within 7 days of that parent post’s creation.
num_users
.
user.country = 'US'
.
pct_users
(as a decimal or percent; specify which in your query).
Note: Task (1) and task (2) have different qualifying criteria; be careful not to mix the populations.