Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
7-Day Rolling Network Traffic
00:00
5 left

7-Day Rolling Network Traffic

HardSQL · PostgreSQL

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
Interviewer

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