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
ExperiencesCoaching
New
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
Get started
Reconcile ERP Actuals to Plan Variances
00:00
5 left

Reconcile ERP Actuals to Plan Variances

MediumSQL · PostgreSQL

Problem

You are given ERP actuals and a planning tool extract for the same fiscal months. Write a PostgreSQL query that reconciles the two sources by account_code and fiscal_month, returns the actual amount, planned amount, and variance, and flags each row as matched, actual_only, plan_only, or mismatch when the numbers do not tie.

Output details

  • Return columns in this order: account_code, fiscal_month, actual_amount, planned_amount, variance, reconciliation_status.
  • Sort ascending by account_code, then ascending by fiscal_month.
  • Use exact equality for matched amounts and compute variance as actual minus planned without rounding or tolerance.
  • Set variance to NULL unless both amounts are present, preserving NULL for the missing amount.
  • Label rows with only actuals as actual_only and rows with only plans as plan_only.

Schema

erp_actuals
ColumnTypeDescription
actual_idPKINTPrimary key for the ERP posting
account_codeVARCHAR(20)General ledger account code
fiscal_monthDATEMonth bucket for the actuals
actual_amountDECIMAL(12,2)Posted ERP amount
source_systemVARCHAR(50)ERP source name
plan_forecast
ColumnTypeDescription
plan_idPKINTPrimary key for the plan row
account_codeVARCHAR(20)Planning account code
fiscal_monthDATEMonth bucket for the plan
planned_amountDECIMAL(12,2)Planned amount from the planning tool
version_nameVARCHAR(50)Plan version
Tableserp_actualsplan_forecast
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the two tables are in the Question tab.

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.