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
US and California Payroll Calculations
00:00
5 left

US and California Payroll Calculations

MediumSQL · PostgreSQL

Problem

Explain payroll calculations in US and California.

Using the provided employee, payroll, and tax-rate data, write a PostgreSQL query that calculates payroll for the January 31, 2025 pay period. Include US employees, apply federal tax to all employees, and apply the applicable state rate, including California.

Output

  1. One row per US employee
  2. Columns: employee_id, employee_name, state_code, gross_pay, pre_tax_deductions, federal_tax, state_tax, and net_pay
  3. Include employees without payroll for the period with zero payroll amounts
  4. Order by employee_id ascending

Schema

employees
ColumnTypeDescription
employee_idPKINTUnique employee identifier
employee_nameVARCHAR(100)Employee's full name
country_codeVARCHAR(2)Employee country code
state_codeVARCHAR(2)US state code
payroll_entries
ColumnTypeDescription
payroll_entry_idPKINTUnique payroll entry identifier
employee_idINTEmployee receiving the payroll entry
pay_period_endDATEEnd date of the pay period
gross_payDECIMAL(12,2)Gross earnings for the entry
pre_tax_deductionsDECIMAL(12,2)Deductions made before tax calculation
tax_rates
ColumnTypeDescription
tax_rate_idPKINTUnique tax-rate identifier
jurisdiction_codeVARCHAR(10)US or state jurisdiction code
tax_typeVARCHAR(20)Federal or state tax category
rateDECIMAL(8,6)Tax rate expressed as a decimal
effective_fromDATEBeginning date for the rate
effective_toDATEEnding date for the rate
Tablesemployeespayroll_entriestax_rates
Interviewer

Your question is US and California Payroll Calculations. 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.