Calculate Distinct High-View Posts and Spam View-Prevalence
Company: Meta
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: Medium
Interview Round: Technical Screen
content_views
| user_id | post_id | view_count | view_date |
| 101 | 572 | 3 | 2021-11-01 |
| 102 | 732 | 5 | 2021-11-02 |
| 103 | 153 | 12 | 2021-11-03 |
| 104 | 634 | 7 | 2021-11-01 |
violating_content
| post_id | violation_type | probability_violating |
| 572 | Spam | 0.70 |
| 732 | Scam | 0.85 |
| 153 | Nudity | 0.95 |
| 634 | Harassment | 0.50 |
##### Scenario
A social platform tracks harmful content and needs SQL reports for ops dashboards.
##### Question
Write SQL to return the count of distinct posts that accumulated more than 10 views within the past 7 days (inclusive). Write SQL to calculate the view-prevalence of Spam or Scam posts during the last 30 days (total Spam/Scam views ÷ total views).
##### Hints
Derive a rolling window from MAX(view_date); join violating_content; filter violation_type IN ('Spam','Scam'); aggregate as required.
Quick Answer: This question evaluates proficiency in SQL-based data manipulation and analytical querying, including joins, aggregation, time-window filtering, and proportion calculations for operational metrics.