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
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess 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
Analyzing Data From a Spreadsheet
00:00
5 left

Analyzing Data From a Spreadsheet

MediumSQL · PostgreSQL

Problem

How would you analyze data from a sample spreadsheet?

Assume the spreadsheet data has been loaded into the provided PostgreSQL tables. Write a query that summarizes January 2025 approved expenses by department and compares activity with each department's monthly budget.

Output

  1. One row per department, including departments with no qualifying expenses.
  2. Return department_name, transaction_count, total_expense, average_expense, monthly_budget, variance_amount, and budget_status.
  3. Include only approved January expenses with non-NULL amounts. Sort by total expense descending, then department name ascending.

Schema

departments
ColumnTypeDescription
department_idPKINTEGERUnique department identifier
department_nameVARCHAR(100)Department name
monthly_budgetNUMERIC(12,2)Monthly expense budget
spreadsheet_expenses
ColumnTypeDescription
expense_idPKINTEGERUnique expense identifier
department_idINTEGERDepartment associated with the expense
expense_dateDATEDate recorded in the spreadsheet
amountNUMERIC(12,2)Expense amount
expense_statusVARCHAR(40)Approval status
expense_typeVARCHAR(60)Expense classification
Tablesdepartmentsspreadsheet_expenses
Interviewer

Your question is Analyzing Data From a Spreadsheet. Start with the requirements and the two 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.