Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.