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
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess 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
Build my plan
SQL for Search Filters Leading to No Results
00:00
5 left

SQL for Search Filters Leading to No Results

MediumSQL · PostgreSQL

Problem

Given a log of user search sessions and conversion events, write a query to find the top three most common search filter combinations that lead to no results.

Use the search_sessions and conversion_events tables. Treat NULL filter values as an explicit filter value, and count conversion events occurring at or after the related search.

Output

  1. One row per filter combination, with filter_combination, no_result_sessions, and conversion_events.
  2. Include only sessions where results_count is zero, return at most three combinations, and sort by no_result_sessions descending, then filter_combination ascending.

Schema

search_sessions
ColumnTypeDescription
session_idPKINTUnique search session identifier
user_idINTUser who performed the search
searched_atTIMESTAMPTimestamp when the search was performed
room_typeVARCHAR(50)Requested Airbnb room type
min_priceINTMinimum nightly price filter
max_priceINTMaximum nightly price filter
guestsINTRequested guest count
results_countINTNumber of listings returned
conversion_events
ColumnTypeDescription
event_idPKINTUnique conversion event identifier
session_idINTSearch session associated with the event
event_typeVARCHAR(30)Conversion event type
event_tsTIMESTAMPTimestamp when the conversion occurred
Tablessearch_sessionsconversion_events
Interviewer

Your question is SQL for Search Filters Leading to No Results. 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.