PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question tests practical SQL skills, specifically the use of LEFT JOIN and aggregate functions to compute engagement metrics across relational tables. It evaluates a data scientist's ability to handle zero-count rows and filter results using set-based logic, competencies commonly assessed in data manipulation interviews.

  • medium
  • Meta
  • Data Manipulation (SQL/Python)
  • Data Scientist

Posts and Replies Engagement

Company: Meta

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: medium

Interview Round: Technical Screen

## Posts and Replies Engagement A content platform stores user-generated **posts** and the **replies** that those posts receive. You need to answer two questions about reply engagement. ### Tables **`posts`** | column | type | description | |-------------|-------------|----------------------------------------------| | `post_id` | INTEGER | Primary key. Unique id of the post. | | `author_id` | INTEGER | Id of the user who created the post. | | `created_at`| TIMESTAMP | When the post was created (UTC). | **`replies`** | column | type | description | |-------------|-------------|--------------------------------------------------------------| | `reply_id` | INTEGER | Primary key. Unique id of the reply. | | `post_id` | INTEGER | Foreign key referencing `posts.post_id`. The post replied to.| | `author_id` | INTEGER | Id of the user who wrote the reply. | | `created_at`| TIMESTAMP | When the reply was created (UTC). | Notes / assumptions: - A post may have zero, one, or many replies. - `replies.post_id` always references an existing row in `posts`. - A user may reply to their own post. - All timestamps are in UTC. ### Part 1 — Reply count per post Return every post together with the number of replies it has received. Posts with **zero** replies must still appear, with a reply count of `0`. Output columns, in this exact order: | column | type | description | |---------------|---------|-----------------------------------| | `post_id` | INTEGER | The post id. | | `reply_count` | INTEGER | Number of replies for that post. | Order the result by `reply_count` descending, breaking ties by `post_id` ascending. ### Part 2 — Posts with no replies Return the `post_id` of every post that has received **no replies at all**. Output column: | column | type | description | |-----------|---------|--------------------------------------| | `post_id` | INTEGER | Id of a post that has zero replies. | Order the result by `post_id` ascending.

Quick Answer: This question tests practical SQL skills, specifically the use of LEFT JOIN and aggregate functions to compute engagement metrics across relational tables. It evaluates a data scientist's ability to handle zero-count rows and filter results using set-based logic, competencies commonly assessed in data manipulation interviews.

Last updated: Jun 21, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Compute ad impression conversion rates - Meta (medium)
  • Count unconnected posts and reactions - Meta (medium)
  • Count heavy callers in 7 days - Meta (medium)
  • Write SQL for call metrics - Meta (medium)
  • Write SQL for multi-account metrics - Meta (medium)