Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Get started
Match Visits Within Five Minutes
00:00
5 left

Match Visits Within Five Minutes

MediumSQL · PostgreSQL

Problem

Tatari needs to measure immediate website response after each ad airing. Write a PostgreSQL query that counts website visits occurring from the airing timestamp through five minutes afterward, including both endpoints.

Requirements

  1. Return one row for every ad airing, including airings with no qualifying visits.
  2. Count each distinct website visit at most once per airing.
  3. Return the airing ID, campaign, airing timestamp, and visit count, ordered chronologically by airing timestamp.

Schema

ad_airings
ColumnTypeDescription
airing_idPKINTEGERUnique identifier for the ad airing
campaign_nameVARCHAR(100)Tatari campaign associated with the airing
aired_atTIMESTAMPTimestamp when the ad aired
website_visits
ColumnTypeDescription
visit_idPKINTEGERUnique identifier for the website visit
visited_atTIMESTAMPTimestamp when the website visit occurred
landing_pageVARCHAR(200)Initial page visited
Tablesad_airingswebsite_visits
Interviewer

Your question is Match Visits Within Five Minutes. Start with the requirements and the two tables 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.