Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Trending in AI
Hot
Agentic AI EngineerForward-Deployed EngineerGenAI EngineerAI Architect
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Start free
Ranked Task Completion by Market and Month
00:00
5 left

Ranked Task Completion by Market and Month

HardSQL · PostgreSQL

Problem

Tell me about how you optimize query performance for large-scale TaskRabbit data workloads.

Write an optimized PostgreSQL query against the supplied TaskRabbit tables that summarizes task workload by provider market, creation month, and task category. Include all tasks in the date range, including tasks without an assignment, and calculate completion metrics and month-over-month completed-task changes.

Output

  1. One row per market, month, and category whose category rank is at most 2 within that market and month.
  2. Columns: market, month_start, category, total_tasks, completed_tasks, completion_rate_pct, previous_completed_tasks, and category_rank.
  3. Sort by market, month_start, category_rank, and category ascending.

Output details

  • Use tasks created on or after 2025-01-01 and before 2025-04-01.
  • Treat missing provider markets as Unassigned.
  • Calculate completion_rate_pct as completed tasks divided by total tasks, multiplied by 100 and rounded to two decimal places.
  • Use dense ranking by descending completed_tasks, allowing all categories tied at rank 2.
  • Calculate previous_completed_tasks from the prior available month for the same market and category, leaving it NULL when unavailable.

Schema

tasks
ColumnTypeDescription
task_idPKINTUnique TaskRabbit task identifier
created_atTIMESTAMPTimestamp when the task was created
categoryVARCHAR(80)Task service category
statusVARCHAR(30)Current task status
feeNUMERIC(10,2)Task fee in dollars
task_assignments
ColumnTypeDescription
task_idPKINTAssigned task identifier
provider_idINTTasker assigned to the task
assigned_atTIMESTAMPAssignment timestamp
providers
ColumnTypeDescription
provider_idPKINTUnique Tasker identifier
provider_nameVARCHAR(100)Tasker display name
marketVARCHAR(60)Provider operating market
provider_tierVARCHAR(30)Provider service tier
Tablestaskstask_assignmentsproviders
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the three tables are in the Question tab.

Sign up free to run or submit. Log in
CodePostgreSQL
Sign up free to run your code. Your draft is saved.Run with a free accountLog inLn 1
Run your query to see results here.