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
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess 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
Build my plan
Detect Anomalous Daily Device Pings
00:00
5 left

Detect Anomalous Daily Device Pings

HardSQL · PostgreSQL

Problem

Detect anomalous daily device pings

You are given daily ping counts from Athelas device telemetry. Write a PostgreSQL query that flags anomalous days per device by comparing each day to the previous available day and by detecting gaps in the daily sequence. Return one row per device-day with the current count, the previous count, the day-over-day change, a gap flag, and an anomaly label. Treat a day as anomalous when the ping count changes by more than 50% versus the previous available day, or when there is a gap of more than 1 day between consecutive records for the same device. Keep the result ordered by device and date.

Schema

device_pings
ColumnTypeDescription
device_idINTDevice identifier
ping_dateDATECalendar date of the daily ping record
ping_countINTNumber of pings recorded that day
firmware_versionVARCHAR(20)Firmware version reported that day
regionVARCHAR(50)Device region; may be NULL
Tablesdevice_pings
Interviewer

Your question is Detect Anomalous Daily Device Pings. 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.