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
LEFT vs INNER Join With Nulls
00:00
5 left

LEFT vs INNER Join With Nulls

MediumSQL · PostgreSQL

Problem

Explain the difference between a LEFT JOIN and an INNER JOIN in terms of performance and output when dealing with null values.

Use the provided State Farm policyholder and auto policy data to demonstrate both join results. Return the join type, policyholder details, and policy details, including unmatched policyholders.

Output

  1. Columns: join_type, policyholder_id, policyholder_name, policy_id, policy_status
  2. Include rows produced by both join types, labeled accordingly
  3. Order by join_type, policyholder_id, and policy_id

Schema

policyholders
ColumnTypeDescription
policyholder_idPKINTUnique policyholder identifier
policyholder_nameVARCHAR(100)Policyholder display name
state_codeVARCHAR(2)Two-letter state code
auto_policies
ColumnTypeDescription
policy_idPKINTUnique auto policy identifier
policyholder_idINTAssociated policyholder identifier
policy_statusVARCHAR(20)Current policy status
coverage_typeVARCHAR(30)Type of auto coverage
Tablespolicyholdersauto_policies
Interviewer

Your question is LEFT vs INNER Join With Nulls. 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.