Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL to Flag Partner Count Mismatches
00:00
5 left

SQL to Flag Partner Count Mismatches

MediumSQL · PostgreSQL

Problem

Write a SQL query to compare partner-reported counts with internal counts and flag mismatches.

Use the provided partner reports and internal event records. Count only internal events whose status is counted; treat missing counts as zero. Include dates present on either side.

Output

  1. One row per partner and date, including unmatched dates.
  2. Columns: partner_id, partner_name, comparison_date, reported_count, internal_count, count_difference, mismatch_flag, and previous_mismatch.
  3. count_difference is reported minus internal. Sort by partner_id, then comparison_date.

Schema

partners
ColumnTypeDescription
partner_idPKVARCHAR(20)Unique partner identifier
partner_nameVARCHAR(100)Partner display name
partner_reports
ColumnTypeDescription
report_idPKINTUnique report record identifier
partner_idVARCHAR(20)Partner that submitted the report
report_dateDATEDate represented by the report
reported_countINTCount submitted by the partner
internal_events
ColumnTypeDescription
event_idPKINTUnique internal event identifier
partner_idVARCHAR(20)Partner associated with the event
event_dateDATEDate on which the event occurred
event_statusVARCHAR(20)Processing status of the event
Tablespartnerspartner_reportsinternal_events
Interviewer

Your question is SQL to Flag Partner Count Mismatches. 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.