PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Data Manipulation (SQL/Python)/Capital One

Write SQL to compute campaign net revenue

Last updated: Mar 29, 2026

Quick Overview

This question evaluates SQL-based data manipulation and analytics skills, including aggregation, deduplication, date-range filtering, revenue and cost calculations, and selection logic for prioritizing additional donors.

  • Medium
  • Capital One
  • Data Manipulation (SQL/Python)
  • Data Scientist

Write SQL to compute campaign net revenue

Company: Capital One

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Onsite

Using the schema and sample data below, write SQL to produce, for each campaign_id and segment, the following metrics for August 2025: total_reached, donors (unique who donated), conversion_rate, gross_donations, variable_cost, fixed_cost, and net_revenue = gross_donations - (fixed_cost + variable_cost). Then, return a one-row summary picking the higher net_revenue between the gala and online campaign. Finally, write a query to suggest the top 10 additional donors (not yet invited to the gala) by last-12-month donation amount to fill remaining gala capacity. Schema: - donors(donor_id INT PRIMARY KEY, segment CHAR(1)) - campaigns(campaign_id INT PRIMARY KEY, name VARCHAR, channel VARCHAR, fixed_cost DECIMAL, variable_cost_per_reach DECIMAL) - contacts(contact_id INT PRIMARY KEY, donor_id INT, campaign_id INT, reached_dt DATE) - donations(donation_id INT PRIMARY KEY, donor_id INT, campaign_id INT, amount DECIMAL, donation_dt DATE) Sample tables (ASCII, minimal rows): Donors +----------+---------+ | donor_id | segment | +----------+---------+ | 1 | H | | 2 | L | | 3 | L | | 4 | H | | 5 | L | +----------+---------+ Campaigns +-------------+------------+---------+------------+------------------------+ | campaign_id | name | channel | fixed_cost | variable_cost_per_reach| +-------------+------------+---------+------------+------------------------+ | 10 | Gala Fall | gala | 20000 | 100 | | 20 | Email Sept | online | 8000 | 1 | +-------------+------------+---------+------------+------------------------+ Contacts +-----------+----------+-------------+------------+ | contact_id| donor_id | campaign_id | reached_dt | +-----------+----------+-------------+------------+ | 101 | 1 | 10 | 2025-08-15 | | 102 | 2 | 10 | 2025-08-15 | | 103 | 4 | 10 | 2025-08-15 | | 201 | 3 | 20 | 2025-08-31 | | 202 | 5 | 20 | 2025-08-31 | +-----------+----------+-------------+------------+ Donations +-------------+----------+-------------+--------+-------------+ | donation_id | donor_id | campaign_id | amount | donation_dt | +-------------+----------+-------------+--------+-------------+ | 301 | 1 | 10 | 1000 | 2025-08-16 | | 302 | 2 | 10 | 250 | 2025-08-16 | | 401 | 3 | 20 | 50 | 2025-09-01 | | 402 | 5 | 20 | 40 | 2025-09-01 | +-------------+----------+-------------+--------+-------------+ Notes: - Treat variable_cost for gala as per attendee (i.e., per contact row for channel='gala'). - For the “top 10 additional donors” query, assume gala capacity is 100, campaign_id=10 currently has COUNT(*) contacts < 100, and there exists a historical table donations_hist(donor_id, amount, donation_dt). Exclude donors already contacted for campaign_id=10.

Quick Answer: This question evaluates SQL-based data manipulation and analytics skills, including aggregation, deduplication, date-range filtering, revenue and cost calculations, and selection logic for prioritizing additional donors.

Related Interview Questions

  • Clean and Merge Housing Data - Capital One (easy)
  • Find Lowest Prices for Highly Rated Categories - Capital One (medium)
  • Merge CSVs and build revenue pivot with pandas - Capital One (Medium)
  • Find top category per region in Aug 2025 - Capital One (Medium)
  • Reconcile ledgers with SQL/Python and late events - Capital One (Medium)
Capital One logo
Capital One
Oct 13, 2025, 9:49 PM
Data Scientist
Onsite
Data Manipulation (SQL/Python)
6
0

Using the schema and sample data below, write SQL to produce, for each campaign_id and segment, the following metrics for August 2025: total_reached, donors (unique who donated), conversion_rate, gross_donations, variable_cost, fixed_cost, and net_revenue = gross_donations - (fixed_cost + variable_cost). Then, return a one-row summary picking the higher net_revenue between the gala and online campaign. Finally, write a query to suggest the top 10 additional donors (not yet invited to the gala) by last-12-month donation amount to fill remaining gala capacity. Schema:

  • donors(donor_id INT PRIMARY KEY, segment CHAR(1))
  • campaigns(campaign_id INT PRIMARY KEY, name VARCHAR, channel VARCHAR, fixed_cost DECIMAL, variable_cost_per_reach DECIMAL)
  • contacts(contact_id INT PRIMARY KEY, donor_id INT, campaign_id INT, reached_dt DATE)
  • donations(donation_id INT PRIMARY KEY, donor_id INT, campaign_id INT, amount DECIMAL, donation_dt DATE) Sample tables (ASCII, minimal rows): Donors +----------+---------+ | donor_id | segment | +----------+---------+ | 1 | H | | 2 | L | | 3 | L | | 4 | H | | 5 | L | +----------+---------+ Campaigns +-------------+------------+---------+------------+------------------------+ | campaign_id | name | channel | fixed_cost | variable_cost_per_reach| +-------------+------------+---------+------------+------------------------+ | 10 | Gala Fall | gala | 20000 | 100 | | 20 | Email Sept | online | 8000 | 1 | +-------------+------------+---------+------------+------------------------+ Contacts +-----------+----------+-------------+------------+ | contact_id| donor_id | campaign_id | reached_dt | +-----------+----------+-------------+------------+ | 101 | 1 | 10 | 2025-08-15 | | 102 | 2 | 10 | 2025-08-15 | | 103 | 4 | 10 | 2025-08-15 | | 201 | 3 | 20 | 2025-08-31 | | 202 | 5 | 20 | 2025-08-31 | +-----------+----------+-------------+------------+ Donations +-------------+----------+-------------+--------+-------------+ | donation_id | donor_id | campaign_id | amount | donation_dt | +-------------+----------+-------------+--------+-------------+ | 301 | 1 | 10 | 1000 | 2025-08-16 | | 302 | 2 | 10 | 250 | 2025-08-16 | | 401 | 3 | 20 | 50 | 2025-09-01 | | 402 | 5 | 20 | 40 | 2025-09-01 | +-------------+----------+-------------+--------+-------------+ Notes:
  • Treat variable_cost for gala as per attendee (i.e., per contact row for channel='gala').
  • For the “top 10 additional donors” query, assume gala capacity is 100, campaign_id=10 currently has COUNT(*) contacts < 100, and there exists a historical table donations_hist(donor_id, amount, donation_dt). Exclude donors already contacted for campaign_id=10.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Data Manipulation (SQL/Python)•More Capital One•More Data Scientist•Capital One Data Scientist•Capital One Data Manipulation (SQL/Python)•Data Scientist Data Manipulation (SQL/Python)
PracHub

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