Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Handling Missing or Inconsistent Data
00:00
5 left

Handling Missing or Inconsistent Data

HardSQL · PostgreSQL

Problem

How do you handle missing or inconsistent data when preparing a report for finance teams?

Using the invoices, customers, and exchange_rates tables, write a SQL query that produces a monthly data-quality reconciliation for January through March 2025.

Output

  1. One row per calendar month, ordered chronologically.
  2. Columns: report_month, invoice_count, accepted_invoice_count, missing_customer_count, missing_rate_count, invalid_amount_count, invalid_status_count, and accepted_amount_usd.
  3. Exclude invoices outside the date range. Treat positive amounts and statuses normalized to posted or paid as valid. Include only invoices with a matching customer, exchange rate, valid amount, and valid status in accepted counts and USD totals.

Schema

invoices
ColumnTypeDescription
invoice_idPKINTUnique invoice identifier
invoice_dateDATEInvoice issue date
customer_idINTCustomer associated with the invoice
amountNUMERIC(14,2)Invoice amount in the invoice currency
currency_codeVARCHAR(20)Invoice currency code
statusVARCHAR(40)Invoice processing status
customers
ColumnTypeDescription
customer_idPKINTUnique customer identifier
customer_nameVARCHAR(120)Customer legal name
regionVARCHAR(60)Customer sales region
exchange_rates
ColumnTypeDescription
currency_codePKVARCHAR(20)Currency converted to USD
rate_datePKDATEFirst day of the applicable month
usd_rateNUMERIC(14,6)USD conversion rate
Tablesinvoicescustomersexchange_rates
Interviewer

Your question is Handling Missing or Inconsistent Data. 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.