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
Rolling Average Payroll Volume
00:00
5 left

Rolling Average Payroll Volume

MediumSQL · PostgreSQL

Problem

Write a SQL window function query to compute a 7-day rolling average of payroll submission volume by business category at Gusto.

Use active business categories and evaluate the date range from January 1 through January 10, 2024. Include dates with no submissions, and calculate averages over the available dates at the beginning of the range.

Output

  1. One row per active business category and calendar date in the range.
  2. Columns: category_name, submission_date, daily_submission_volume, and rolling_7_day_average.
  3. Include zero-volume dates and order by category_name, then submission_date.

Schema

business_categories
ColumnTypeDescription
category_idPKINTUnique business category identifier
category_nameVARCHAR(100)Business category name
is_activeBOOLEANWhether the category is currently active
payroll_submissions
ColumnTypeDescription
submission_idPKINTUnique payroll submission identifier
category_idINTBusiness category associated with the submission
submitted_atTIMESTAMPTimestamp when the payroll was submitted
Tablesbusiness_categoriespayroll_submissions
Interviewer

Your question is Rolling Average Payroll Volume. 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.