Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Clean Null Campaign Metrics
00:00
5 left

Clean Null Campaign Metrics

EasySQL · PostgreSQL

Problem

You are given a single table of daily StackAdapt campaign performance metrics. Some rows have missing values in impressions, clicks, or spend. Write a SQL query that returns each campaign_name with the number of rows that contain at least one null metric and the average spend after treating null spend values as 0.

This tests whether you can handle incomplete performance data safely in PostgreSQL without dropping rows that still matter for reporting.

Schema

campaign_metrics
ColumnTypeDescription
idPKINTUnique row identifier
campaign_nameVARCHAR(100)StackAdapt campaign name
metric_dateDATEDate of the performance record
impressionsINTNumber of impressions served
clicksINTNumber of clicks recorded
spendDECIMAL(10,2)Daily spend in dollars
Tablescampaign_metrics
Interviewer

Your question is Clean Null Campaign Metrics. Start with the requirements and the one table in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.