Count Advertisers With a Reels Placement Without Join Duplication

Last updated: November 29, 2026

Quick Overview

Count Meta advertisers who ran at least one campaign with a Reels placement last month, and their total spend on all placements, without the join to placements inflating either number.

Meta
Data Manipulation (SQL/Python)
Data Scientist
Meta
November 29, 2026
Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
Easy

0

0

0 solved


Count Meta advertisers who ran at least one campaign with a Reels placement last month, and their total spend on all placements, without the join to placements inflating either number.

Meta ads tables are deeply nested (advertiser, campaign, ad set, placement), and this screen question checks semi-join thinking. The interviewer wants EXISTS for the filter and pre-aggregation for the spend, rather than joining everything and hoping DISTINCT fixes it.

What the Interviewer Expects
  • Uses EXISTS (a semi join) to filter advertisers
  • Computes spend from the spend table directly, not through the placement join
  • Explains how a plain join multiplies spend
  • Notes COUNT(DISTINCT) fixes counts but not sums
  • Scopes both filter and spend to last month
Key Topics to Cover
semi join
EXISTS
join fan-out
pre-aggregation
ads
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you report spend on Reels only versus all placements?
  • What if a campaign's placements changed during the month?
  • How would you compute the share of advertisers using Reels?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

campaigns(campaign_id, advertiser_id), ad_set_placements(ad_set_id, campaign_id, placement) with many rows per campaign (feed, stories, reels, and so on), and `campaign_spend(campaign_id, spend_da...

Approach

Joining spend to placements repeats each spend row once per placement row, so a campaign with four placements has its spend counted four times. COUNT(DISTINCT advertiser_id) would still be right, bu...


Submit Your Answer
Markdown supported