Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Query for Expected Results

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is SQL Query for Expected Results. Start with the requirements and the three tables on the right.

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.

Problem

Guidewire PolicyCenter needs an operational summary of active policies and their 2025 claims. Write a PostgreSQL query that produces one row per qualifying policy, including policies with no matching claims.

Requirements

  1. Include only policies with status = 'ACTIVE' and an effective_date on or before December 31, 2025.
  2. Count claims reported during calendar year 2025.
  3. Sum only COMPLETED claim payments, showing zero when no completed payment exists.
  4. Sort by policy_number ascending. Use a CTE to aggregate payments before joining, preventing claim payment rows from inflating claim counts.

Schema

policycenter_policies
ColumnTypeDescription
policy_idPKINTPrimary policy identifier
policy_numberVARCHAR(20)Guidewire PolicyCenter policy number
insured_nameVARCHAR(100)Named insured
statusVARCHAR(20)Current policy status
product_lineVARCHAR(40)Policy product line
effective_dateDATEPolicy effective date
claims
ColumnTypeDescription
claim_idPKINTPrimary claim identifier
policy_idINTRelated policy identifier
reported_dateDATEDate the claim was reported
statusVARCHAR(20)Claim lifecycle status
claim_payments
ColumnTypeDescription
payment_idPKINTPrimary payment identifier
claim_idINTRelated claim identifier
amountNUMERIC(12,2)Payment amount
payment_statusVARCHAR(20)Payment processing status
Tablespolicycenter_policiesclaimsclaim_payments
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results