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
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess 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
Start free
SQL With Double Joins
00:00
5 left

SQL With Double Joins

MediumSQL · PostgreSQL

Problem

Explain how you would solve an SQL problem involving double joins.

Use the supplied customers, policies, and claims tables. Include customers without policies and policies without claims in the results.

Output

  1. One row per customer.
  2. Columns: customer_id, customer_name, policy_count, approved_claim_count, and approved_claim_amount.
  3. Include all customers, with zero-valued metrics where no matching records exist.
  4. Order by customer_id ascending.

Schema

customers
ColumnTypeDescription
customer_idPKINTUnique customer identifier
customer_nameVARCHAR(100)Customer display name
policies
ColumnTypeDescription
policy_idPKINTUnique policy identifier
customer_idINTCustomer who owns the policy
policy_typeVARCHAR(50)Policy classification
claims
ColumnTypeDescription
claim_idPKINTUnique claim identifier
policy_idINTPolicy associated with the claim
claim_statusVARCHAR(30)Current claim status
claim_amountDECIMAL(12,2)Claimed amount
Tablescustomerspoliciesclaims
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the three tables are in the Question tab.

Sign up free to run or submit. Log in
CodePostgreSQL
Sign up free to run your code. Your draft is saved.Run with a free accountLog inLn 1
Run your query to see results here.