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
ExperiencesCoaching
New
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
Get started
Time Series Forecasting and Error Metrics
00:00
5 left

Time Series Forecasting and Error Metrics

MediumSQL · PostgreSQL

Problem

Describe a time series forecasting problem you worked on and explain the difference between RMSE and MAE.

Using actual_values and forecast_values, write a SQL query that calculates both error metrics for each forecasting model. Exclude observations where either the actual or forecast value is missing.

Output

  1. One row per model with model_name, observations_used, mae, and rmse
  2. Order by rmse ascending, then model_name ascending

Schema

actual_values
ColumnTypeDescription
actual_idPKINTUnique actual observation identifier
observation_dateDATEDate of the observed value
actual_valueNUMERIC(12,2)Observed value for the date
forecast_values
ColumnTypeDescription
forecast_idPKINTUnique forecast identifier
model_nameVARCHAR(40)Name of the forecasting model
forecast_dateDATEDate being forecast
forecast_valueNUMERIC(12,2)Predicted value for the date
Tablesactual_valuesforecast_values
Interviewer

Your question is Time Series Forecasting and Error Metrics. 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.