Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
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
Sign up free to run your codeLog inLn 1
Run your query to see results here.