Campaigns That Overspent Their Budget

Find campaigns that spent more than their daily_budget on more than 7 days. Report the number of overspend days and the total amount spent above budget on those days.

Expected output

name, daily_budget, overspend_days, overspend_amount (rounded to 2 decimals). Sorted by overspend_amount descending.

Row order is checked. Column names are not checked; numbers are compared to 2 decimals.

Dataset: Digital ads performance

A retailer's paid campaigns across search, social, display and video in February 2026: daily delivery, individual ad clicks and purchases.

campaigns

One row per campaign.

campaign_idINTEGERprimary key
nameTEXT
channelTEXTsearch, social, display or video
start_dateTEXTYYYY-MM-DD
end_dateTEXTYYYY-MM-DD inclusive, NULL if still running
daily_budgetREALUSD
ad_daily

Delivery per campaign per day it ran, as reported by the ad platform. clicks is the platform's count, which may differ from our own click log.

campaign_idINTEGER
dayTEXTYYYY-MM-DD
impressionsINTEGER
clicksINTEGER
spendREALUSD
ad_clicks

Our own click log: one row per ad click that reached the site and was tracked.

click_idINTEGERprimary key, increases with clicked_at
campaign_idINTEGER
user_idINTEGER
clicked_atTEXTYYYY-MM-DD HH:MM:SS (UTC)
conversions

One row per purchase. Some purchases come from users who never clicked an ad.

conversion_idINTEGERprimary key
user_idINTEGER
converted_atTEXTYYYY-MM-DD HH:MM:SS (UTC)
revenueREALUSD

Engine: SQLite. Dates are text (YYYY-MM-DD); use strftime(), date() and julianday() for date math.

Related problems

SQLite · runs in your browser
Ctrl/⌘ + Enter to run
Expected output preview (6 rows, order matters)
namedaily_budgetoverspend_daysoverspend_amount
Competitor Search15946.49
Brand Search181143.55
Social Retargeting51319

Showing 3 of 6 rows.

Hints

Worked solution

Run at least one query to unlock it.