Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Ensuring Data Accuracy
00:00
5 left

Ensuring Data Accuracy

MediumSQL · PostgreSQL

Problem

How do you ensure accuracy when working with sensitive financial or liability data?

Write a SQL query using the policies, liability_transactions, and ledger_entries tables to identify policies with missing data, null financial amounts, or differences between posted liability and ledger totals. Treat differences of 0.01 or less as accurate.

Output

  1. One row per policy requiring review.
  2. Return policy_id, liability_total, ledger_total, variance, and review_status.
  3. Order by the absolute variance descending, then policy_id ascending.

Schema

policies
ColumnTypeDescription
policy_idPKINTUnique policy identifier
policy_statusVARCHAR(20)Current policy status
product_nameVARCHAR(60)Policy product name
liability_transactions
ColumnTypeDescription
transaction_idPKINTUnique liability transaction identifier
policy_idINTRelated policy identifier
transaction_typeVARCHAR(30)Type of liability transaction
amountDECIMAL(14,2)Transaction amount
transaction_statusVARCHAR(20)Posting status
ledger_entries
ColumnTypeDescription
entry_idPKINTUnique ledger entry identifier
policy_idINTRelated policy identifier
amountDECIMAL(14,2)Ledger amount
entry_statusVARCHAR(20)Ledger posting status
source_systemVARCHAR(30)Originating finance system
Tablespoliciesliability_transactionsledger_entries
Interviewer

Your question is Ensuring Data Accuracy. 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.