CPU Utilization Summary

An easy SQL interview practice problem on DataDriven. Write the query and run it against a real database, with instant feedback.

Domain
SQL
Difficulty
easy
Seniority
L3
Asked in
ESPN

Problem

The capacity planning team wants a one-line summary of fleet-wide CPU health: the minimum, average, and maximum CPU utilization across all infrastructure nodes.

The CPUs are working. How hard?

Tables

infra_nodes

Columns: node_id INTEGER, hostname TEXT, region TEXT, node_type TEXT, cpu_pct REAL, mem_pct REAL, status TEXT

infra_nodes: 10 of 200 rows
node_idhostnameregionnode_typecpu_pctmem_pctstatus
1037web-02us-west-2memory1319stopped
1074api-01eu-west-1storage2638draining
1111api-02sa-east-1gpu3957offline
1148db-primaryeu-central-1general5276Running
1185db-replicaus-east-1compute6595STOPPED
1222cache-01us-west-2memory7814running
1259worker-01eu-west-1StorageNULLNULLstopped
1296worker-02ap-south-1gpu452draining
1333gpu-node-01eu-central-1general1771offline
1370WEB-03us-east-1compute3090Running

Expected output

First 1 of 1 rows
min_cpuavg_cpumax_cpu
048.7790697674418699

Worked solution and explanation

Why this problem exists in real interviews

This tests basic aggregate functions (MIN, AVG, MAX) without GROUP BY. It produces a single summary row, screening for fundamental aggregate fluency.


Break down the requirements

Step 1: Compute three aggregates

MIN(cpu_pct), AVG(cpu_pct), and MAX(cpu_pct) in a single SELECT without GROUP BY produces one summary row.


The solution

Fleet-wide aggregate summary
SELECT
    MIN(cpu_pct) AS min_cpu,
    AVG(cpu_pct) AS avg_cpu,
    MAX(cpu_pct) AS max_cpu
FROM infra_nodes

Common follow-up questions