PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates proficiency in data manipulation and analytics, testing skills such as joining event and impression tables, aggregating time-series revenue, and counting distinct active ads broken down by creation source.

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

Compute active ad revenue by creation source

Company: Meta

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Onsite

You work on an ads platform and need to report **active ad revenue** broken down by the ad’s **creation source**. ## Tables ### `ads` - `ad_id` BIGINT **PK** - `advertiser_id` BIGINT - `creation_source` VARCHAR *Examples:* `'SELF_SERVE'`, `'MANAGED'`, `'API'` - `created_at` TIMESTAMP ### `ad_impressions` - `impression_id` BIGINT **PK** - `ad_id` BIGINT **FK → ads.ad_id** - `impression_time` TIMESTAMP ### `ad_revenue_events` - `event_id` BIGINT **PK** - `ad_id` BIGINT **FK → ads.ad_id** - `event_time` TIMESTAMP - `revenue_usd` DECIMAL(18,6) *(Assume revenue is recorded at the time it is earned, e.g., per impression/click.)* ## Definitions / assumptions - Timezone: **UTC**. - A paid ad is **active on a day** if it has **≥ 1 impression** that day. - **Active ad revenue on a day** = sum of `revenue_usd` from `ad_revenue_events` that occurred that day **for ads that are active that same day**. ## Task Write a SQL query to compute, for each calendar day in a given date range (e.g., `:start_date` to `:end_date`, inclusive): - `report_date` - `creation_source` - `active_ads` (count of distinct active `ad_id`) - `active_ad_revenue_usd` (sum of revenue for active ads) Order results by `report_date`, then `creation_source`.

Quick Answer: This question evaluates proficiency in data manipulation and analytics, testing skills such as joining event and impression tables, aggregating time-series revenue, and counting distinct active ads broken down by creation source.

Last updated: Mar 29, 2026

Loading coding console...

PracHub

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

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)