PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates a candidate's ability to compute advertising metrics from event-level logs using SQL, specifically aggregating impressions and clicks and calculating click-through rates across and by campaign dimensions.

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

Calculate Weekly CTR and Campaign-Specific CTR in SQL

Company: Meta

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Technical Screen

AdEvents ad_id | campaign_id | event | view_id | event_date 1 | 10 | impression | 123 | 2023-11-07 1 | 10 | click | 123 | 2023-11-07 2 | 11 | impression | 124 | 2023-11-07 3 | 12 | impression | 125 | 2023-11-07 3 | 12 | click | 125 | 2023-11-07 ​ Campaigns campaign_id | campaign_type 10 | direct_response 11 | brand 12 | direct_response ##### Scenario You have event-level logs of ad impressions and clicks plus a lookup of campaign types. Management wants click-through-rate (CTR) numbers for last week. ##### Question Write SQL to compute overall CTR (clicks / impressions) across all ads for the last calendar week. Write SQL to compute CTR broken out by campaign_type for the same period. ##### Hints Filter by event_date, join tables, count impressions and clicks separately, then divide using CAST to avoid integer division.

Quick Answer: This question evaluates a candidate's ability to compute advertising metrics from event-level logs using SQL, specifically aggregating impressions and clicks and calculating click-through rates across and by campaign dimensions.

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)