Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL for Overdue Work by Owner
00:00
5 left

SQL for Overdue Work by Owner

MediumSQL · PostgreSQL

Problem

Given tables for tasks, owners, and status updates, how would you find overdue work and summarize it by owner using SQL at Attentive?

Use 2025-02-01 as the reporting date. A task is overdue when its due date is before that date and its latest status is not Completed. Include tasks without status updates and tasks without an assigned owner.

Output

  1. One row per owner, including Unassigned when applicable.
  2. Columns: owner_id, owner_name, overdue_count, and overdue_task_ids.
  3. Sort by overdue count descending, then owner name ascending.

Schema

owners
ColumnTypeDescription
owner_idPKINTUnique owner identifier
owner_nameVARCHAR(100)Owner's display name
team_nameVARCHAR(100)Attentive team assigned to the owner
tasks
ColumnTypeDescription
task_idPKINTUnique task identifier
task_nameVARCHAR(200)Task title
owner_idINTAssigned owner, when one exists
due_dateDATETask due date
created_atDATETask creation date
status_updates
ColumnTypeDescription
status_update_idPKINTUnique status update identifier
task_idINTTask associated with the update
statusVARCHAR(50)Status recorded by the update
updated_atTIMESTAMPTimestamp when the status was recorded
Tablestasksownersstatus_updates
Interviewer

Your question is SQL for Overdue Work by Owner. Start with the requirements and the three tables 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.