Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Rolling Average Robot Task Times

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

Your question is Rolling Average Robot Task Times. Start with the requirements and the two 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

UiPath Automation Cloud stores execution telemetry for attended and unattended robots. Write a PostgreSQL query that reports the rolling average execution time for each robot across its current execution and two preceding completed executions.

Requirements

  1. Join robots with robot_task_executions and return the robot name, execution identifier, start time, and execution duration.
  2. Include only executions with status = 'completed' and a non-NULL execution duration.
  3. Calculate a three-row rolling average separately for each robot, ordered by started_at and then execution_id to break timestamp ties.
  4. Return the results in robot and chronological execution order.

Schema

robots
ColumnTypeDescription
robot_idPKINTEGERUnique UiPath robot identifier
robot_nameVARCHAR(100)UiPath robot display name
machine_nameVARCHAR(100)Machine connected to the robot
robot_task_executions
ColumnTypeDescription
execution_idPKINTEGERUnique task execution identifier
robot_idINTEGERRobot that ran the task
task_nameVARCHAR(150)UiPath process or task name
started_atTIMESTAMPExecution start timestamp
execution_time_secondsINTEGERExecution duration in seconds
statusVARCHAR(20)Execution state
Tablesrobotsrobot_task_executions
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results