Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
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
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
SQL and Python for Analytics
00:00
5 left

SQL and Python for Analytics

HardSQL · PostgreSQL

Problem

Describe your experience using Microsoft SQL Server and Python to analyze data and produce insights for finance stakeholders.

For this practical exercise, write a PostgreSQL query that reconciles monthly actuals and budgets by cost center. Include cost centers appearing on only one side, calculate profitability variance, compare each cost center with its prior reported month, and rank results within each month.

Output

  1. One row per cost center and reported month, excluding rows with a NULL cost center ID or month.
  2. Return cost_center_name, month_start, actual and budget revenue, actual and budget expense, profit_variance, prior_variance, and monthly_variance_rank.
  3. Sort by month, descending profit variance, then cost center name.

Schema

cost_centers
ColumnTypeDescription
cost_center_idPKINTUnique cost center identifier
cost_center_nameVARCHAR(80)Finance reporting name
finance_actuals
ColumnTypeDescription
actual_idPKINTUnique actual transaction identifier
cost_center_idINTRelated cost center identifier
month_startDATEFirst day of the reporting month
actual_revenueNUMERIC(14,2)Recognized revenue amount
actual_expenseNUMERIC(14,2)Recognized expense amount
finance_budgets
ColumnTypeDescription
budget_idPKINTUnique budget record identifier
cost_center_idINTRelated cost center identifier
month_startDATEFirst day of the budget month
budget_revenueNUMERIC(14,2)Budgeted revenue amount
budget_expenseNUMERIC(14,2)Budgeted expense amount
Tablescost_centersfinance_actualsfinance_budgets
Interviewer

Your question is SQL and Python for Analytics. 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.