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
Daily CTR by Category
00:00
5 left

Daily CTR by Category

MediumSQL · PostgreSQL

Problem

Given a table of customer search queries and clicked results, write a query to calculate the click-through rate (CTR) for each category on a daily basis on Thumbtack.

Use the provided search and click tables. Count each search query once, even when it has multiple clicked results, and exclude rows with a missing category.

Output

  1. One row per date and category, with search_date, category, searches, clicked_searches, and ctr_percent.
  2. Include categories with no clicks, order by search_date ascending and category ascending.

Schema

search_queries
ColumnTypeDescription
query_idPKINTUnique identifier for a customer search query
searched_atTIMESTAMPTimestamp when the search was submitted
categoryVARCHAR(100)Thumbtack service category associated with the search
clicked_results
ColumnTypeDescription
click_idPKINTUnique identifier for a clicked result event
query_idINTSearch query that produced the clicked result
clicked_atTIMESTAMPTimestamp when the result was clicked
Tablessearch_queriesclicked_results
Interviewer

Your question is Daily CTR by Category. 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.