Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Rolling 7-Day System Error Average

HardSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Rolling 7-Day System Error Average. Start with the requirements and the one table on the right.

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.

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
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results