Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Verify Policy-to-Claims Cascade
00:00
5 left

Verify Policy-to-Claims Cascade

MediumSQL · PostgreSQL

Problem

How do you query a database to verify that a policy update correctly cascaded to related claims records?

Write a PostgreSQL query that evaluates the latest applied update for each policy against claims that existed when the update was applied. Treat a claim as compliant only when its policy version and limit match the update.

Output

  1. One row per policy with an applied update.
  2. Return policy_id, policy_name, update_id, expected_version, expected_limit, related_claim_count, compliant_claim_count, noncompliant_claim_count, and cascade_status.
  3. Include policies with no qualifying claims, classify them as verified, and order by policy_id.

Schema

policies
ColumnTypeDescription
policy_idPKINTEGERUnique policy identifier
policy_nameVARCHAR(100)Display name of the policy
policy_typeVARCHAR(40)Insurance policy category
policy_updates
ColumnTypeDescription
update_idPKINTEGERUnique policy update identifier
policy_idINTEGERPolicy affected by the update
new_versionINTEGERPolicy version introduced by the update
new_limitNUMERIC(12,2)Policy limit introduced by the update
update_statusVARCHAR(20)Lifecycle status of the update
applied_atTIMESTAMPTZTimestamp when the update was applied
claims
ColumnTypeDescription
claim_idPKINTEGERUnique claim identifier
policy_idINTEGERPolicy associated with the claim
claim_opened_atTIMESTAMPTZTimestamp when the claim was opened
policy_versionINTEGERPolicy version stored on the claim
policy_limitNUMERIC(12,2)Policy limit stored on the claim
claim_statusVARCHAR(20)Current claim status
Tablespoliciespolicy_updatesclaims
Interviewer

Your question is Verify Policy-to-Claims Cascade. 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.