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 for Telemetry
00:00
5 left

Rolling Average for Telemetry

MediumSQL · PostgreSQL

Problem

Volkswagen Group Italia wants to monitor vehicle operating conditions from telemetry collected across its connected-vehicle fleet. Write a PostgreSQL query that calculates a time-based 30-day rolling average for each vehicle's battery temperature readings.

Requirements

  1. Join telemetry_readings to vehicles and include the vehicle model in the output.
  2. Return only battery_temperature readings, including rows where the reading value is NULL.
  3. Calculate the average for the current reading and all readings for the same vehicle recorded during the preceding 30 days, using a window function ordered by recorded_at.
  4. Return results ordered by vehicle ID and recording timestamp. Round the rolling average to two decimal places.

Schema

vehicles
ColumnTypeDescription
vehicle_idPKINTEGERUnique vehicle identifier
modelVARCHAR(80)Volkswagen vehicle model
marketVARCHAR(40)Sales market
telemetry_readings
ColumnTypeDescription
reading_idPKINTEGERUnique telemetry reading identifier
vehicle_idINTEGERReferenced vehicle identifier
metric_nameVARCHAR(50)Telemetry metric name
reading_valueNUMERIC(8,2)Measured metric value
recorded_atTIMESTAMPTime when the reading was captured
Tablesvehiclestelemetry_readings
Interviewer

Your question is Rolling Average for Telemetry. 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.