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 Problem Solving
00:00
5 left

SQL Problem Solving

HardSQL · PostgreSQL

Problem

Tell me about a time you were asked to solve various problems in SQL.

For this exercise, use the provided Insurify-style operational tables and write one query that answers the requested business questions from the same dataset. Keep the result set compact and deterministic.

Output

  1. One row per customer who has at least one completed quote and at least one policy event.
  2. Return customer_id, customer_name, completed_quotes, policy_events, first_completed_quote_date, last_policy_event_date, and days_between_first_and_last.
  3. Include only customers whose completed quotes are greater than zero and whose policy events are greater than zero.
  4. Sort by days_between_first_and_last descending, then customer_id ascending.

Schema

customers
ColumnTypeDescription
customer_idPKINTUnique customer identifier
customer_nameVARCHAR(255)Customer full name
stateVARCHAR(50)Customer state
quotes
ColumnTypeDescription
quote_idPKINTUnique quote identifier
customer_idINTReferences customers.customer_id
quote_statusVARCHAR(50)Quote status such as completed or abandoned
quote_created_atDATEDate the quote was created
policy_events
ColumnTypeDescription
event_idPKINTUnique policy event identifier
customer_idINTReferences customers.customer_id
event_typeVARCHAR(50)Policy event type
event_dateDATEDate of the policy event
Tablescustomersquotespolicy_events
Interviewer

Your question is SQL Problem Solving. Start with the requirements and the three 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.