Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Trending in AI
Hot
Agentic AI EngineerForward-Deployed EngineerGenAI EngineerAI Architect
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

Write a SQL Query

MediumSQL & Data Manipulation00:00
Practice interviewer
In session
5 left
00:00

Whenever you're ready, walk me through how you'd approach this.

Sign up free to chat or submit. Log in

Problem

Chubb underwrites commercial property and casualty policies, and the claims team wants a state-by-state view of payout exposure. You are given the schema below and asked to write the SQL query yourself, on the spot, rather than fix an existing one.

CREATE TABLE policies (
    policy_id INT PRIMARY KEY,
    policyholder_name VARCHAR(120),
    policy_type VARCHAR(40),
    state CHAR(2),
    effective_date DATE,
    premium_amount NUMERIC(10,2)
);

CREATE TABLE claims (
    claim_id INT PRIMARY KEY,
    policy_id INT REFERENCES policies(policy_id),
    claim_date DATE,
    claim_amount NUMERIC(10,2),
    claim_status VARCHAR(20)  -- 'Approved', 'Denied', 'Pending'
);

Write a single SQL query that returns, for every state, the total approved-or-pending claim amount paid out over the last 12 months and the number of distinct policyholders who filed one of those claims, restricted to states with at least 5 qualifying claims, sorted by total payout descending. Explain the query you would write and why.