Reconcile Daily Clicks with Click Logs

Data quality check: for each campaign, compare the total clicks reported in ad_daily with the number of rows in ad_clicks. Show both numbers and the difference.

Expected output

campaign_id, name, reported_clicks, logged_clicks, diff (reported - logged). Sorted by campaign_id.

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 (12 rows, order matters)
campaign_idnamereported_clickslogged_clicksdiff
1Brand Search2182180
2Generic Search - Shoes2052050
3Competitor Search1511510

Showing 3 of 12 rows.

Hints

Worked solution

Run at least one query to unlock it.