Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
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 feedbackCoaching1:1 coaching with people at your target companiesSuccess 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 10% Underperforming Zones
00:00
5 left

Top 10% Underperforming Zones

HardSQL · PostgreSQL

Problem

Swiggy Operations wants to identify active delivery zones with the longest completed-order delivery times. Write a PostgreSQL query that returns the top 10% of qualifying zones by average delivery duration.

Requirements

  1. Join swiggy_zones with swiggy_deliveries using zone_id.
  2. Consider only active zones and deliveries with status = 'DELIVERED' and non-null timestamps.
  3. Calculate average delivery time in minutes and the number of completed deliveries per zone.
  4. Rank zones from slowest to fastest and return CEIL(10% of qualifying zones), with ties resolved by zone_id.

Schema

swiggy_zones
ColumnTypeDescription
zone_idPKINTEGERUnique Swiggy delivery zone identifier
zone_nameVARCHAR(80)Name of the delivery zone
cityVARCHAR(60)City containing the zone
is_activeBOOLEANWhether the zone is currently active
swiggy_deliveries
ColumnTypeDescription
delivery_idPKINTEGERUnique delivery identifier
zone_idINTEGERDelivery zone associated with the order
statusVARCHAR(20)Delivery lifecycle status
accepted_atTIMESTAMPTimestamp when the delivery was accepted
delivered_atTIMESTAMPTimestamp when the order was delivered
Tablesswiggy_zonesswiggy_deliveries
Interviewer

Your question is Top 10% Underperforming Zones. 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.