PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Data Manipulation (SQL/Python)/Meta

Compute view prevalence from views and labels

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's competency in temporal joins, stateful deduplication of moderation decisions, time-aware aggregation, and prevalence metric calculations within content-moderation analytics.

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

Compute view prevalence from views and labels

Company: Meta

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Technical Screen

Given the tables below, write SQL to compute view prevalence of violating content. Use “today” = 2025-09-01 and report the last 7 days (2025-08-26 to 2025-09-01 inclusive). Provide two variants per country and day: Ex-ante prevalence counts a view as violating only if a VIOLATION decision existed at or before the view timestamp; Ex-post prevalence uses the final decision regardless of when it was detected. Then, list the top 3 creators by ex-post violating_view_share over this window and break down their violating views by surface. Schema and small samples: Tables: content_views(view_ts TIMESTAMP, user_id INT, content_id INT, surface VARCHAR, country VARCHAR) content_moderation(content_id INT, decision VARCHAR, violation_type VARCHAR, detected_ts TIMESTAMP, source VARCHAR, is_removed BOOLEAN) content(content_id INT, creator_id INT, created_ts TIMESTAMP, country VARCHAR) Samples: content | content_id | creator_id | created_ts | country | | 101 | 1001 | 2025-08-25 10:00:00 | US | | 102 | 1002 | 2025-08-30 12:00:00 | US | | 103 | 1003 | 2025-08-31 08:00:00 | CA | content_views | view_ts | user_id | content_id | surface | country | | 2025-08-26 09:00:00 | 504 | 101 | feed | US | | 2025-08-30 18:00:00 | 501 | 102 | feed | US | | 2025-08-31 20:00:00 | 501 | 101 | feed | US | | 2025-09-01 09:00:00 | 502 | 102 | feed | US | | 2025-09-01 10:00:00 | 503 | 103 | search | CA | content_moderation | content_id | decision | violation_type | detected_ts | source | is_removed | | 101 | VIOLATION | spam | 2025-08-31 21:00:00 | human | true | | 102 | CLEAN | NULL | 2025-08-30 14:00:00 | model | false | | 103 | VIOLATION | hate_speech | 2025-09-01 12:00:00 | model | true | Implementation details to reflect in SQL: treat the latest decision per content_id as the final decision for ex-post; for ex-ante, use the most recent decision with detected_ts <= view_ts. Assume contents without any moderation row at view time are CLEAN for ex-ante. Return: (view_date, country, total_views, violating_views_ex_ante, violating_views_ex_post, ex_ante_prevalence, ex_post_prevalence). Then compute the creator-level breakdown requested.

Quick Answer: This question evaluates a candidate's competency in temporal joins, stateful deduplication of moderation decisions, time-aware aggregation, and prevalence metric calculations within content-moderation analytics.

Related Interview 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)
Meta logo
Meta
Oct 13, 2025, 9:49 PM
Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
5
0

Given the tables below, write SQL to compute view prevalence of violating content. Use “today” = 2025-09-01 and report the last 7 days (2025-08-26 to 2025-09-01 inclusive). Provide two variants per country and day: Ex-ante prevalence counts a view as violating only if a VIOLATION decision existed at or before the view timestamp; Ex-post prevalence uses the final decision regardless of when it was detected. Then, list the top 3 creators by ex-post violating_view_share over this window and break down their violating views by surface. Schema and small samples:

Tables: content_views(view_ts TIMESTAMP, user_id INT, content_id INT, surface VARCHAR, country VARCHAR) content_moderation(content_id INT, decision VARCHAR, violation_type VARCHAR, detected_ts TIMESTAMP, source VARCHAR, is_removed BOOLEAN) content(content_id INT, creator_id INT, created_ts TIMESTAMP, country VARCHAR)

Samples: content | content_id | creator_id | created_ts | country | | 101 | 1001 | 2025-08-25 10:00:00 | US | | 102 | 1002 | 2025-08-30 12:00:00 | US | | 103 | 1003 | 2025-08-31 08:00:00 | CA |

content_views | view_ts | user_id | content_id | surface | country | | 2025-08-26 09:00:00 | 504 | 101 | feed | US | | 2025-08-30 18:00:00 | 501 | 102 | feed | US | | 2025-08-31 20:00:00 | 501 | 101 | feed | US | | 2025-09-01 09:00:00 | 502 | 102 | feed | US | | 2025-09-01 10:00:00 | 503 | 103 | search | CA |

content_moderation | content_id | decision | violation_type | detected_ts | source | is_removed | | 101 | VIOLATION | spam | 2025-08-31 21:00:00 | human | true | | 102 | CLEAN | NULL | 2025-08-30 14:00:00 | model | false | | 103 | VIOLATION | hate_speech | 2025-09-01 12:00:00 | model | true |

Implementation details to reflect in SQL: treat the latest decision per content_id as the final decision for ex-post; for ex-ante, use the most recent decision with detected_ts <= view_ts. Assume contents without any moderation row at view time are CLEAN for ex-ante. Return: (view_date, country, total_views, violating_views_ex_ante, violating_views_ex_post, ex_ante_prevalence, ex_post_prevalence). Then compute the creator-level breakdown requested.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Data Manipulation (SQL/Python)•More Meta•More Data Scientist•Meta Data Scientist•Meta Data Manipulation (SQL/Python)•Data Scientist Data Manipulation (SQL/Python)
PracHub

Master your tech interviews with 7,500+ 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.