Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
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 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
Build my plan
Rolling 30-Day Applications Average
00:00
5 left

Rolling 30-Day Applications Average

MediumSQL · PostgreSQL

Problem

United Auto Credit wants a daily view of loan application volume across active dealerships. Write a PostgreSQL query that calculates the rolling 30-day average of daily applications.

Requirements

  1. Count applications by calendar day using submitted_at, including days with zero applications.
  2. Include applications submitted through active dealerships only.
  3. Calculate the average daily application count for the current day and preceding 29 calendar days using a window function.
  4. Return one row per day, ordered chronologically, with the application date, daily count, and rolling average.

Schema

loan_applications
ColumnTypeDescription
application_idPKINTUnique loan application identifier
dealership_idINTReferences the dealership associated with the application
submitted_atDATEDate the application was submitted
dealerships
ColumnTypeDescription
dealership_idPKINTUnique dealership identifier
dealership_nameVARCHAR(100)Dealership name
regionVARCHAR(50)United Auto Credit operating region
is_activeBOOLEANWhether the dealership is currently active
Tablesloan_applicationsdealerships
Interviewer

Your question is Rolling 30-Day Applications Average. 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.