Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Policy Update Cascades in SQL
00:00
5 left

Policy Update Cascades in SQL

MediumSQL · PostgreSQL

Problem

Write a SQL query to verify that a specific policy update correctly cascaded to the claims database. Use update_id = 1002 as the specific update. Compare eligible claims with the policy update and its audit records, identifying missing applications, mismatched limits, and stale references.

Output

  1. One row for update 1002
  2. Columns: update_id, policy_id, expected_claim_count, cascaded_claim_count, missing_audit_count, mismatched_limit_count, stale_reference_count, cascade_status
  3. Return PASS only when all eligible claims were correctly updated and audited; otherwise return FAIL.

Schema

policy_updates
ColumnTypeDescription
update_idPKINTUnique policy update identifier
policy_idINTPolicy affected by the update
old_coverage_limitNUMERIC(12,2)Coverage limit before the update
new_coverage_limitNUMERIC(12,2)Coverage limit expected after the update
updated_atTIMESTAMPTime the policy update became effective
statusVARCHAR(20)Policy update processing status
claims
ColumnTypeDescription
claim_idINTBusiness identifier for the claim
claim_versionINTVersion number for the claim
policy_idINTPolicy associated with the claim
claim_created_atTIMESTAMPClaim creation timestamp
claim_updated_atTIMESTAMPClaim version update timestamp
claim_statusVARCHAR(20)Current claim status
coverage_limitNUMERIC(12,2)Coverage limit stored on the claim
policy_update_idINTPolicy update applied to the claim
claim_update_audit
ColumnTypeDescription
audit_idPKINTUnique audit record identifier
claim_idINTClaim affected by the update
policy_update_idINTPolicy update recorded by the audit event
applied_atTIMESTAMPTime the cascade was recorded
source_systemVARCHAR(30)System that recorded the audit event
Tablespolicy_updatesclaimsclaim_update_audit
Interviewer

Your question is Policy Update Cascades in SQL. 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.