Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Rolling 7-Day System Error Average
00:00
5 left

Rolling 7-Day System Error Average

MediumSQL · PostgreSQL

Problem

You are given daily system error logs and asked to calculate a rolling 7-day average of errors for each day in the series. Use PostgreSQL-compatible SQL to return one row per calendar day with the daily error count and the 7-day trailing average, including days with zero errors. Do not use MySQL-only syntax.

Schema

system_errors
ColumnTypeDescription
error_idPKINTPrimary key for each error event
occurred_atTIMESTAMPTimestamp when the error occurred
system_nameVARCHAR(100)Name of the system that emitted the error
severityVARCHAR(20)Error severity level
Tablessystem_errors
Interviewer

Your question is Rolling 7-Day System Error Average. Start with the requirements and the one table 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.