PracHub
QuestionsCoachesLearningGuidesInterview Prep
|Home/Data Manipulation (SQL/Python)/Bytedance

Campaign Efficiency Metrics and Below-Average CTR

Last updated: Jul 9, 2026

Quick Overview

Practice a data scientist SQL interview question that calculates campaign cost and funnel rates, handles zero denominators, and filters campaigns against an average CTR benchmark. The exercise tests PostgreSQL date arithmetic, CTE organization, NULL-safe calculations, and deterministic output.

  • medium
  • Bytedance
  • Data Manipulation (SQL/Python)
  • Data Scientist

Campaign Efficiency Metrics and Below-Average CTR

Company: Bytedance

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: medium

Interview Round: Technical Screen

# Campaign Efficiency Metrics and Below-Average CTR You are given an `ad_campaigns` table with one row per campaign: | Column | Type | Meaning | | --- | --- | --- | | `campaign_id` | INTEGER | Unique campaign identifier | | `campaign_name` | VARCHAR | Campaign name | | `start_date` | DATE | First active date, inclusive | | `end_date` | DATE | Last active date, inclusive | | `daily_budget` | DECIMAL | Planned budget per active day | | `impressions` | INTEGER | Recorded impressions | | `clicks` | INTEGER | Recorded clicks | | `conversions` | INTEGER | Recorded conversions | For this console, use PostgreSQL and the following explicit assumptions: campaign dates are inclusive, each row covers one entire campaign, and `daily_budget` is constant across its active dates. Write one query that returns only campaigns whose campaign-level click-through rate is below the arithmetic mean of the valid campaign-level click-through rates. Return these columns: - `campaign_id` - `campaign_name` - `total_cost`: `daily_budget` multiplied by the inclusive number of active dates - `ctr`: `clicks / impressions` - `conversion_rate`: `conversions / clicks` - `cost_per_conversion`: `total_cost / conversions` Use decimal division. When a denominator is zero, return `NULL` for that rate rather than raising an error. Campaigns with zero impressions do not contribute to the average CTR and cannot be classified as below it. Order the final rows by `campaign_id`. After writing the query, be prepared to explain whether `daily_budget × active_days` represents actual spend or only planned budget.

Quick Answer: Practice a data scientist SQL interview question that calculates campaign cost and funnel rates, handles zero denominators, and filters campaigns against an average CTR benchmark. The exercise tests PostgreSQL date arithmetic, CTE organization, NULL-safe calculations, and deterministic output.

Related Interview Questions

  • Find high-value crypto users and top CTR - Bytedance (hard)
  • Find top-paid employee per department - Bytedance (medium)
|Home/Data Manipulation (SQL/Python)/Bytedance

Campaign Efficiency Metrics and Below-Average CTR

Bytedance logo
Bytedance
Apr 4, 2026, 12:00 AM
mediumData ScientistTechnical ScreenData Manipulation (SQL/Python)
0
0

Campaign Efficiency Metrics and Below-Average CTR

You are given an ad_campaigns table with one row per campaign:

ColumnTypeMeaning
campaign_idINTEGERUnique campaign identifier
campaign_nameVARCHARCampaign name
start_dateDATEFirst active date, inclusive
end_dateDATELast active date, inclusive
daily_budgetDECIMALPlanned budget per active day
impressionsINTEGERRecorded impressions
clicksINTEGERRecorded clicks
conversionsINTEGERRecorded conversions

For this console, use PostgreSQL and the following explicit assumptions: campaign dates are inclusive, each row covers one entire campaign, and daily_budget is constant across its active dates.

Write one query that returns only campaigns whose campaign-level click-through rate is below the arithmetic mean of the valid campaign-level click-through rates.

Return these columns:

  • campaign_id
  • campaign_name
  • total_cost : daily_budget multiplied by the inclusive number of active dates
  • ctr : clicks / impressions
  • conversion_rate : conversions / clicks
  • cost_per_conversion : total_cost / conversions

Use decimal division. When a denominator is zero, return NULL for that rate rather than raising an error. Campaigns with zero impressions do not contribute to the average CTR and cannot be classified as below it. Order the final rows by campaign_id.

After writing the query, be prepared to explain whether daily_budget × active_days represents actual spend or only planned budget.

Loading comments...

Browse More Questions

More Data Manipulation (SQL/Python)•More Bytedance•More Data Scientist•Bytedance Data Scientist•Bytedance Data Manipulation (SQL/Python)•Data Scientist Data Manipulation (SQL/Python)

Write your answer

Your first approved answer each day earns 20 XP.

Sign in to write your answer.
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding 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.