Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

7-Day Rolling Network Traffic

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

Your question is 7-Day Rolling Network Traffic. 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

Juniper Networks uses daily telemetry from Juniper Mist and Junos devices to monitor network demand. Write a PostgreSQL query that calculates a seven-day rolling average of daily traffic and compares it with the immediately preceding seven-day period.

Requirements

  1. Aggregate traffic by calendar date, treating missing dates and NULL traffic values as zero.
  2. Generate a contiguous daily time series so each rolling window represents seven calendar days.
  3. Calculate the current seven-day average, the previous seven-day average, the absolute change, and the percentage change.
  4. Return only dates with two complete, non-overlapping seven-day periods, ordered chronologically.

Schema

network_traffic_daily
ColumnTypeDescription
traffic_idPKINTUnique telemetry record identifier
traffic_dateDATEDate of the traffic measurement
device_groupVARCHAR(40)Juniper device group or product family
traffic_gbNUMERIC(10,2)Traffic volume in gigabytes
Tablesnetwork_traffic_daily
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results