Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
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
Experiences
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
Build my plan
Top Personal Shoppers by Performance
00:00
5 left

Top Personal Shoppers by Performance

MediumSQL · PostgreSQL

Problem

Given a transactional database table, write a query to identify top-performing personal shoppers based on delivery speed and customer ratings.

Use completed deliveries, require at least two completed deliveries and two non-null customer ratings per shopper, and return the top two shoppers. Delivery speed is measured in minutes from pickup to delivery.

Output

  1. One row per qualifying shopper with shopper_id, shopper_name, avg_delivery_minutes, avg_rating, completed_deliveries, and performance_rank.
  2. Sort by rank ascending, then shopper ID ascending. Faster average delivery ranks higher, followed by higher rating and more completed deliveries.

Schema

shoppers
ColumnTypeDescription
shopper_idPKINTUnique personal shopper identifier
shopper_nameVARCHAR(100)Personal shopper name
statusVARCHAR(20)Current shopper status
deliveries
ColumnTypeDescription
delivery_idPKINTUnique delivery identifier
shopper_idINTPersonal shopper assigned to the delivery
statusVARCHAR(20)Delivery lifecycle status
picked_up_atTIMESTAMPTimestamp when the order was picked up
delivered_atTIMESTAMPTimestamp when the order was delivered
customer_ratings
ColumnTypeDescription
rating_idPKINTUnique rating identifier
delivery_idINTDelivery being rated
rating_valueNUMERIC(2,1)Customer rating from 1.0 to 5.0
Tablesshoppersdeliveriescustomer_ratings
Interviewer

Your question is Top Personal Shoppers by Performance. 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.