Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Efficient Telemetry Aggregation Query

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

Your question is Efficient Telemetry Aggregation Query. Start with the requirements and the three tables 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

Caterpillar's fleet monitoring system needs a daily summary of telemetry for active machines operating at North American sites. Write a PostgreSQL query that aggregates readings while preserving active machines that have no telemetry during the reporting period.

Requirements

  1. Include active machines at sites where region = 'North America' for January 1 through January 3, 2026.
  2. Return one row per machine and telemetry date with reading count, average engine temperature, and maximum fuel rate.
  3. Preserve machines without readings using LEFT JOIN, and label each row as NO DATA, UNAVAILABLE, HIGH, ELEVATED, or NORMAL based on the aggregated temperature.
  4. Order the result by machine ID and telemetry date, with machines without readings included at the end of their machine group.

Schema

cat_sites
ColumnTypeDescription
site_idPKINTUnique Caterpillar operating or test site identifier
site_nameVARCHAR(120)Name of the operating or test site
regionVARCHAR(40)Geographic region used for reporting
cat_machines
ColumnTypeDescription
machine_idPKINTUnique machine identifier
modelVARCHAR(40)Caterpillar machine model
site_idINTOperating site reference
statusVARCHAR(20)Current machine lifecycle status
telemetry_readings
ColumnTypeDescription
reading_idPKINTUnique telemetry reading identifier
machine_idINTMachine that emitted the reading
reading_atTIMESTAMPTimestamp when the reading was captured
engine_temp_cDECIMAL(6,2)Engine temperature in degrees Celsius
fuel_rate_lphDECIMAL(8,2)Fuel consumption rate in liters per hour
Tablescat_sitescat_machinestelemetry_readings
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results