Compute Unattended Robot Machine Utilization Over a Reporting Window
Last updated: November 29, 2026
Quick Overview
Given a jobs table (job_id, machine_id, start_time, end_time, state) and a machines table, compute for each machine the share of a reporting window that it spent running jobs, the number of jobs touching the window, and the faulted job rate. Jobs can straddle the window edges and running jobs have a null end_time.
UiPath
November 29, 20260
0
0 solved
Given a jobs table (job_id, machine_id, start_time, end_time, state) and a machines table, compute for each machine the share of a reporting window that it spent running jobs, the number of jobs touching the window, and the faulted job rate. Jobs can straddle the window edges and running jobs have a null end_time.
Customers size their unattended robot fleets and licenses from Orchestrator and Insights reports, so analytics and data engineering candidates are expected to turn raw job logs into trustworthy utilization numbers. The interviewer looks for correct interval clipping, handling of open jobs, and keeping idle machines in the output.
What the Interviewer Expects
- Clips each job interval to the window instead of counting whole durations
- Treats null end_time as still running up to now
- Uses a LEFT JOIN so machines with no jobs report zero
- Guards the faulted rate against division by zero
- Explains how to sanity check the numbers
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- Two jobs overlap on the same machine (high-density robots). How does utilization change and how would you merge intervals?
- How would you report utilization per hour of day to show where capacity is wasted?
- The jobs table has 2 billion rows. How would you make this report cheap to run daily?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
Times are UTC timestamps. state is one of Successful, Faulted, Stopped, Running. A job counts if it overlaps the window [:w_start, :w_end). Running jobs have end_time IS NULL and should count up...
Approach
- Filter to jobs that overlap the window:
start_time < w_end AND coalesce(end_time, now()) > w_start. - Clip each to
greatest(start, w_start)andleast(end, w_end). - Left join from machines,...