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
Analyze Time Series Data
00:00
5 left

Analyze Time Series Data

MediumSQL · PostgreSQL

Problem

How do you approach the analysis of time series data?

Write a PostgreSQL query that summarizes the supplied time series observations by calendar month. Include only valid observations with non-null values, while retaining series that have no qualifying observations. Mark the latest available month for each series.

Output

  1. One row per series and available month, plus one null-month row for series without qualifying observations.
  2. Columns: series_id, series_name, month_start, average_value, observation_count, and is_latest_month.
  3. Order by series_id, then month_start ascending, with null months last.

Schema

time_series
ColumnTypeDescription
series_idPKINTUnique identifier for a time series
series_nameVARCHAR(100)Human-readable name of the time series
frequencyVARCHAR(20)Expected observation frequency
is_activeBOOLEANWhether the series is currently active
observations
ColumnTypeDescription
observation_idPKINTUnique identifier for an observation
series_idINTReferenced time series identifier
observed_atDATEDate on which the value was observed
valueNUMERIC(10,2)Observed numeric value
quality_statusVARCHAR(20)Validation status of the observation
Tablestime_seriesobservations
Interviewer

Your question is Analyze Time Series Data. 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.