Post Reaction Count

ASKED IN INTERVIEW
2pts
Meta

Problem Statement

Meta tracks various types of reactions on posts to measure user sentiment. For this task, the product team wants to know the combined total of positive engagement—specifically Like and Heart reactions—for a single post with post_id 1001.

Write an SQL query to find the total number of Like and Heart reactions for post_id 1001.

Rules:

  • Only count reactions where reaction_type is exactly Like or Heart.
  • The query should target post_id 1001.
  • Output columns: post_id, total_positive_reactions.
  • Results should be returned in descending order based on the total count (though for a single ID, this is trivial).

Table Schema:

  • Reactions: reaction_id, post_id, user_id, reaction_type (Like, Heart, Laugh, Sad, Angry), reacted_at.
Tests your understanding of
Basic SQL, Filtering and Aggregation

Input Tables

Reactions
post_id(INTEGER)reaction_type(VARCHAR)
1001Like
1001Heart
1001Like
1001Sad
1002Heart
1001Heart
1001Like

Expected Output

post_id(INTEGER)total_positive_reactions(INTEGER)
10015

Tags

EasyASKED IN INTERVIEWBasic SQLFilteringAggregation
5-10 min
82%

Hints