Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Investigate Retail Partner Data Discrepancies

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

Your question is Investigate Retail Partner Data Discrepancies. Start with the requirements and the four 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

You are given internal order data, partner-reported totals, and discrepancy reason codes. Write a PostgreSQL query that helps investigate a recurring data discrepancy by returning, for each partner and day, the internal order count, internal revenue, partner-reported revenue, the revenue delta, and a discrepancy status that labels rows as match, underreported, overreported, or missing_report. Only include days where the partner reported data or the internal system has orders.

Schema

retail_partners
ColumnTypeDescription
partner_idPKINTPrimary key for the retail partner
partner_nameVARCHAR(100)Partner display name
partner_reports
ColumnTypeDescription
report_idPKINTPrimary key for the partner report row
partner_idINTForeign key to retail_partners.partner_id
report_dateDATEDate covered by the report
reported_revenueNUMERIC(12,2)Revenue reported by the partner
reported_order_countINTOrder count reported by the partner
internal_orders
ColumnTypeDescription
order_idPKINTPrimary key for the internal order
partner_idINTForeign key to retail_partners.partner_id
order_dateDATEOrder date in the internal system
order_amountNUMERIC(12,2)Revenue from the internal system
discrepancy_reasons
ColumnTypeDescription
reason_idPKINTPrimary key for the discrepancy reason
partner_idINTForeign key to retail_partners.partner_id
reason_dateDATEDate the reason was logged
reason_codeVARCHAR(50)Reason code such as late_feed, mapping_error, or promo_mismatch
Tablesretail_partnerspartner_reportsinternal_ordersdiscrepancy_reasons
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results