Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
DAU with Three Tasks in 24 Hours
00:00
5 left

DAU with Three Tasks in 24 Hours

MediumSQL · PostgreSQL

Problem

Write a query to find the daily active users (DAU) who successfully completed at least three automated tasks within a 24-hour window.

Use the users and task_executions tables. Include only successful executions whose task type is automated. Treat a task completed exactly 24 hours earlier as within the window.

Output

  1. One row per qualifying user and calendar date.
  2. Return activity_date, user_id, and completed_tasks_in_24h.
  3. Include only users with at least three qualifying tasks in a 24-hour window.
  4. Order by activity_date ascending, then user_id ascending.

Schema

users
ColumnTypeDescription
user_idPKINTUnique user identifier
display_nameVARCHAR(100)User display name
task_executions
ColumnTypeDescription
execution_idPKINTUnique task execution identifier
user_idINTUser who initiated the execution
task_typeVARCHAR(30)Execution type, such as automated or manual
statusVARCHAR(30)Execution result status
completed_atTIMESTAMPTimestamp when the execution completed
Tablesuserstask_executions
Interviewer

Your question is DAU with Three Tasks in 24 Hours. Start with the requirements and the two 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.